@farm.js/core 0.1.72 → 0.1.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-mcp-handler-VIT4GOSR.mjs → agent-mcp-handler-HX4F4VKN.mjs} +4 -4
- package/dist/{agent-mcp-handler-KE4J3W7S.cjs → agent-mcp-handler-NRIL4JBC.cjs} +5 -5
- package/dist/{agent-mcp.d-Cwff7lcA.d.mts → agent-mcp.d-BEhDfdWc.d.mts} +1 -1
- package/dist/{agent-mcp.d-BO3rZXEM.d.ts → agent-mcp.d-CX8_oOT_.d.ts} +1 -1
- package/dist/agent-runtime.cjs +4 -4
- package/dist/agent-runtime.d.mts +5 -5
- package/dist/agent-runtime.d.ts +5 -5
- package/dist/agent-runtime.mjs +3 -3
- package/dist/{analyzer-5Q75LTIL.mjs → analyzer-2K35LIQZ.mjs} +2 -2
- package/dist/analyzer-6EOYURMV.cjs +16 -0
- package/dist/api/client.d.mts +3 -3
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.native.d.mts +4 -4
- package/dist/api/client.native.d.ts +4 -4
- package/dist/api/node.cjs +9 -8
- package/dist/api/node.d.mts +7 -7
- package/dist/api/node.d.ts +7 -7
- package/dist/api/node.mjs +8 -7
- package/dist/api/route-manager.cjs +11 -9
- package/dist/api/route-manager.d.mts +10 -8
- package/dist/api/route-manager.d.ts +10 -8
- package/dist/api/route-manager.mjs +10 -8
- package/dist/api/runtime.cjs +8 -7
- package/dist/api/runtime.d.mts +6 -6
- package/dist/api/runtime.d.ts +6 -6
- package/dist/api/runtime.mjs +7 -6
- package/dist/{api-client.d-Bp35zMqR.d.mts → api-client.d-CyVmI4Di.d.mts} +2 -2
- package/dist/{api-client.d-CFI_xL0V.d.ts → api-client.d-DrTM7BdH.d.ts} +2 -2
- package/dist/api.cjs +13 -11
- package/dist/api.d.mts +10 -10
- package/dist/api.d.ts +10 -10
- package/dist/api.mjs +12 -10
- package/dist/{app-manifest.d-USD_IbFd.d.mts → app-manifest.d-BcXt2yCx.d.mts} +10 -1
- package/dist/{app-manifest.d-DwjGkYlP.d.ts → app-manifest.d-CVEx1CFB.d.ts} +10 -1
- package/dist/app-markdown.cjs +8 -4
- package/dist/app-markdown.d.mts +7 -7
- package/dist/app-markdown.d.ts +7 -7
- package/dist/app-markdown.mjs +7 -3
- package/dist/{app.d-DAmF2MAk.d.ts → app.d-B6i8CSrx.d.ts} +36 -4
- package/dist/{app.d-fW06_h8h.d.mts → app.d-DowzSmT5.d.mts} +36 -4
- package/dist/cache.cjs +2 -2
- package/dist/cache.d.mts +8 -0
- package/dist/cache.d.ts +8 -0
- package/dist/cache.mjs +1 -1
- package/dist/chunk-2DOI6HLJ.cjs +284 -0
- package/dist/chunk-2GQBBOFH.mjs +76 -0
- package/dist/{chunk-5LOARKDP.cjs → chunk-2TZ3F6TN.cjs} +29 -17
- package/dist/{chunk-IWCYRDRQ.cjs → chunk-35GBGSQZ.cjs} +3 -3
- package/dist/{chunk-GF22VGMS.cjs → chunk-3BUJIPKE.cjs} +2 -2
- package/dist/{chunk-Y5LEPEVH.mjs → chunk-3ODLJRA6.mjs} +1 -1
- package/dist/{chunk-DMAP4RND.cjs → chunk-3OMLZLDE.cjs} +54 -16
- package/dist/{chunk-VNBDN5W2.cjs → chunk-47ZDUDN5.cjs} +64 -27
- package/dist/{chunk-2W4GNXGX.cjs → chunk-4AB62NMW.cjs} +2 -2
- package/dist/{chunk-HDPT6OYE.cjs → chunk-4M5ESTJ2.cjs} +10 -2
- package/dist/{chunk-CBLRSZQL.cjs → chunk-56HHUSR5.cjs} +502 -430
- package/dist/chunk-5XD2ULJG.mjs +114 -0
- package/dist/{chunk-JX5VOLAV.cjs → chunk-65OS2TOT.cjs} +4 -4
- package/dist/{chunk-WIJF3PBM.mjs → chunk-6JEXH7N6.mjs} +1 -1
- package/dist/{chunk-TY5KCYDE.mjs → chunk-72NTEYCX.mjs} +10 -3
- package/dist/{chunk-5R4Q5FN7.cjs → chunk-737MIVX3.cjs} +52 -41
- package/dist/{chunk-5X6OHJEE.cjs → chunk-77SVUQM5.cjs} +74 -20
- package/dist/{chunk-CKQAQFF6.mjs → chunk-7RKHXF4P.mjs} +2 -2
- package/dist/{chunk-GJEC5S4V.mjs → chunk-7VCLTNED.mjs} +1 -1
- package/dist/{chunk-E3LE6EZH.cjs → chunk-ACAEFEOH.cjs} +38 -41
- package/dist/{chunk-REP6HWJN.mjs → chunk-AL6E63FZ.mjs} +2 -2
- package/dist/{chunk-DQ2DI3Y7.mjs → chunk-AO5IRA2N.mjs} +2 -2
- package/dist/{chunk-VAWDGGW3.mjs → chunk-AU5UPNOD.mjs} +26 -15
- package/dist/{chunk-DS7JGFW5.mjs → chunk-B3XY6FMC.mjs} +71 -17
- package/dist/{chunk-U7VH3Q5E.cjs → chunk-B5WZP3T3.cjs} +15 -2
- package/dist/{chunk-3JN5M3T5.mjs → chunk-BFOMCSZ2.mjs} +476 -138
- package/dist/{chunk-I4KPA2C6.mjs → chunk-BIX46FTI.mjs} +1 -1
- package/dist/{chunk-YZLEOMMA.mjs → chunk-BNXV3PRM.mjs} +4 -4
- package/dist/{chunk-3GNVIYPO.cjs → chunk-BSJMWCWM.cjs} +7 -7
- package/dist/{chunk-WVQNXXNE.cjs → chunk-BWFBTTJ5.cjs} +2 -2
- package/dist/{chunk-FEFCISOX.cjs → chunk-CEVXKJKF.cjs} +2 -2
- package/dist/{chunk-DGNMXL2O.mjs → chunk-CF77L6RL.mjs} +33 -36
- package/dist/{chunk-OB45EAQL.mjs → chunk-CXQZQK6R.mjs} +3 -2
- package/dist/{chunk-255J7K4X.mjs → chunk-D2IAYGYA.mjs} +1 -1
- package/dist/{chunk-OSEQL34Q.cjs → chunk-D4TYE6MY.cjs} +2 -2
- package/dist/{chunk-FSSONJRV.cjs → chunk-DM2YGTRH.cjs} +24 -17
- package/dist/{chunk-ICFPTHXM.mjs → chunk-DRBXYJZ6.mjs} +7 -3
- package/dist/{chunk-E3HDJCWF.mjs → chunk-DRHHTHA3.mjs} +1 -1
- package/dist/{chunk-YXIQYWOK.cjs → chunk-DTBRSRTR.cjs} +23 -5
- package/dist/{chunk-JZQS3ZOI.mjs → chunk-E4T7WJJN.mjs} +10 -2
- package/dist/{chunk-YAEN3L2F.cjs → chunk-EF5AP4CV.cjs} +21 -2
- package/dist/{chunk-SPP3EZTJ.cjs → chunk-EHJOSIXM.cjs} +137 -67
- package/dist/{chunk-JZBU7V4D.mjs → chunk-ELJQWUAR.mjs} +125 -55
- package/dist/{chunk-DMXMIE2C.cjs → chunk-ENYBDM4U.cjs} +2 -2
- package/dist/{chunk-ZFEJ2SF2.cjs → chunk-EWIEJQP6.cjs} +28 -28
- package/dist/{chunk-ZUVAGMQ5.cjs → chunk-F244KE2D.cjs} +7 -7
- package/dist/{chunk-WW3LRNQV.mjs → chunk-FCBUNILW.mjs} +1 -1
- package/dist/{chunk-645ENY7W.mjs → chunk-FEQ72ZHD.mjs} +16 -9
- package/dist/{chunk-ME7RVELR.mjs → chunk-FGXSWRWA.mjs} +20 -1
- package/dist/{chunk-2AFW7673.cjs → chunk-FNWL5DMG.cjs} +4 -3
- package/dist/{chunk-HLMUWKAP.cjs → chunk-FYV6DTAG.cjs} +826 -531
- package/dist/{chunk-7PPLTD3P.cjs → chunk-G7S6XG6X.cjs} +6 -6
- package/dist/{chunk-AQIO3RNL.mjs → chunk-GK2GBIXD.mjs} +3 -3
- package/dist/{chunk-IHTDLCDJ.cjs → chunk-GRHSQYD4.cjs} +17 -4
- package/dist/{chunk-W44X6IC2.cjs → chunk-HBLYSWIJ.cjs} +13 -9
- package/dist/chunk-HK4VJI27.cjs +76 -0
- package/dist/{chunk-EGIY4A7V.cjs → chunk-HKZVC5GP.cjs} +2 -2
- package/dist/{chunk-EYPSKXO4.mjs → chunk-HRQV5Q3J.mjs} +1 -1
- package/dist/{chunk-S7MWSFFP.cjs → chunk-IBEHVSU4.cjs} +2 -2
- package/dist/{chunk-77VNYVVX.mjs → chunk-IG4IQMIW.mjs} +1 -1
- package/dist/{chunk-N3XO5AL5.cjs → chunk-IJFNXP3D.cjs} +2 -2
- package/dist/{chunk-RFWWXEIF.mjs → chunk-IP2R2TAE.mjs} +1 -1
- package/dist/{chunk-FETMUBIA.mjs → chunk-IZ5WOTQP.mjs} +1 -1
- package/dist/{chunk-CSLHNBPS.cjs → chunk-J42QN7OC.cjs} +6 -6
- package/dist/{chunk-NDDRTFN4.mjs → chunk-J7EUGGTY.mjs} +2 -2
- package/dist/{chunk-5XFKWHZD.mjs → chunk-JI6N4W2I.mjs} +208 -136
- package/dist/{chunk-GJ7QVFAG.mjs → chunk-JOECBGY7.mjs} +1 -1
- package/dist/{chunk-CL52PD6D.cjs → chunk-JSUVQ5HG.cjs} +8 -8
- package/dist/{chunk-DZHTNSQ5.cjs → chunk-JWHRVBCZ.cjs} +14 -14
- package/dist/{chunk-OSMUE5ST.mjs → chunk-JZ43UD6S.mjs} +7 -7
- package/dist/{chunk-RLEALQEN.mjs → chunk-KIRIFO6T.mjs} +43 -5
- package/dist/{chunk-XGTFLG73.cjs → chunk-KMYOKQPP.cjs} +18 -11
- package/dist/{chunk-WX63N6C5.mjs → chunk-KNEYWPZV.mjs} +64 -27
- package/dist/{chunk-AYVGD3PK.mjs → chunk-KUMKBBYP.mjs} +1 -1
- package/dist/{chunk-VT25ERQK.mjs → chunk-KWUZJZ23.mjs} +21 -3
- package/dist/{chunk-NV26EGMC.mjs → chunk-LHFGTR7F.mjs} +2 -2
- package/dist/{chunk-4P5634G6.cjs → chunk-LIQJYEQP.cjs} +14 -9
- package/dist/chunk-LRPPXKCX.mjs +58 -0
- package/dist/chunk-LXTYJ2HW.mjs +139 -0
- package/dist/{chunk-O32QPFVV.cjs → chunk-MKQ27TGW.cjs} +5 -5
- package/dist/{chunk-KQAB5LML.mjs → chunk-MQ5HA7H2.mjs} +2 -2
- package/dist/{chunk-Z3GPAFIA.mjs → chunk-MUITBU5Z.mjs} +1 -1
- package/dist/chunk-NDOE76QC.cjs +58 -0
- package/dist/{chunk-EXN4DTVF.cjs → chunk-NET6PBUH.cjs} +2 -2
- package/dist/{chunk-YBY34UHB.mjs → chunk-NKETXVKP.mjs} +15 -2
- package/dist/chunk-NRWEY2CM.mjs +25 -0
- package/dist/chunk-NU5XLYRN.cjs +139 -0
- package/dist/{chunk-BE7AQXJB.cjs → chunk-NXGQIXR7.cjs} +507 -169
- package/dist/{chunk-C5AM2XDN.cjs → chunk-O2A6HE76.cjs} +4 -4
- package/dist/{chunk-OAEDVXVE.mjs → chunk-O6K4G7YA.mjs} +5 -2
- package/dist/{chunk-LXEJNWF5.mjs → chunk-OSKIG4OP.mjs} +2 -2
- package/dist/{chunk-3WG7GJQL.cjs → chunk-P3EZKU6L.cjs} +18 -18
- package/dist/{chunk-C2JOS77Z.cjs → chunk-PG6ZIHKE.cjs} +250 -51
- package/dist/{chunk-ET6WW3FY.cjs → chunk-Q3MVNRAO.cjs} +1305 -848
- package/dist/{chunk-AZ6IW6SF.mjs → chunk-Q4G52OSW.mjs} +1 -1
- package/dist/{chunk-TPYAYFMF.cjs → chunk-QL3YZTGZ.cjs} +2 -2
- package/dist/{chunk-JMFTKNBA.mjs → chunk-R4BWNP73.mjs} +2 -2
- package/dist/{chunk-J5ASGNKF.mjs → chunk-R6Q6VSGU.mjs} +24 -9
- package/dist/{chunk-B6RBJJ5G.mjs → chunk-RBRIKT6B.mjs} +15 -2
- package/dist/{chunk-C6CUUBY5.cjs → chunk-RHI67C2V.cjs} +5 -5
- package/dist/chunk-RK3YYUX6.cjs +114 -0
- package/dist/{chunk-Y2LU4LE5.mjs → chunk-ROPMQNCG.mjs} +2 -2
- package/dist/{chunk-QIXEU2WV.cjs → chunk-RQ4UZJPR.cjs} +3 -3
- package/dist/{chunk-ZDZUFD67.cjs → chunk-RSL3YFJG.cjs} +1 -1
- package/dist/{chunk-JWY66PID.cjs → chunk-S3D6SL2V.cjs} +9 -6
- package/dist/{chunk-4HGLJOXZ.cjs → chunk-TPDKFRQX.cjs} +11 -11
- package/dist/{chunk-E2V7RRFL.mjs → chunk-UHAARKF3.mjs} +2 -2
- package/dist/{chunk-QSTRBKHZ.mjs → chunk-UJWRXBVP.mjs} +2 -2
- package/dist/{chunk-7QCJDYZQ.cjs → chunk-V6T3UJAH.cjs} +7 -7
- package/dist/{chunk-AUAMXI6N.mjs → chunk-VFPFXMTF.mjs} +1 -1
- package/dist/{chunk-KPJYBSHL.mjs → chunk-VKLV7GF4.mjs} +221 -22
- package/dist/{chunk-TP4RAV7Y.cjs → chunk-VKRMO3EZ.cjs} +8 -8
- package/dist/chunk-VWIW47FW.cjs +25 -0
- package/dist/{chunk-L6E4SHUB.cjs → chunk-VZKCGHWC.cjs} +39 -24
- package/dist/{chunk-JWLRBDDC.cjs → chunk-WH3PBJS7.cjs} +2 -2
- package/dist/{chunk-BSXKZPFE.mjs → chunk-WS4SLJW5.mjs} +501 -206
- package/dist/{chunk-5OFNUETM.mjs → chunk-WTTJ2YS2.mjs} +9 -1
- package/dist/{chunk-RLFGKJQ6.mjs → chunk-X2KNHD4B.mjs} +14 -2
- package/dist/{chunk-5CFHQ7HM.mjs → chunk-XXKMAHYE.mjs} +1 -1
- package/dist/{chunk-MBCRWU3P.cjs → chunk-XZPI44Q7.cjs} +4 -4
- package/dist/{chunk-ACGBXN3U.cjs → chunk-Y4FEQBKY.cjs} +17 -9
- package/dist/{chunk-MWUDEYBI.mjs → chunk-YH33PZ3K.mjs} +1 -1
- package/dist/chunk-YQWRBBAA.mjs +284 -0
- package/dist/{chunk-QUYAGU65.mjs → chunk-YWDRWG4L.mjs} +1210 -753
- package/dist/{chunk-E46NXBNJ.mjs → chunk-ZD7JUTBY.mjs} +11 -6
- package/dist/{chunk-JDO346NV.mjs → chunk-ZLRWO5GK.mjs} +1 -1
- package/dist/{chunk-NAXKOTPP.cjs → chunk-ZRCGPSUM.cjs} +21 -21
- package/dist/{chunk-YCNHUIPR.cjs → chunk-ZZGANFQH.cjs} +10 -10
- package/dist/client/lifecycle.d.mts +1 -1
- package/dist/client/lifecycle.d.ts +1 -1
- package/dist/{client-component.d-9J7CkTWW.d.ts → client-component.d-DYOwmq0c.d.ts} +80 -3
- package/dist/{client-component.d-ciHeCxr-.d.mts → client-component.d-edV76QvU.d.mts} +80 -3
- package/dist/{client-plugins.d-CUOhfapO.d.ts → client-plugins.d-BmJYW2FY.d.ts} +20 -7
- package/dist/{client-plugins.d-JnRz5a1o.d.mts → client-plugins.d-DwvqqGsU.d.mts} +20 -7
- package/dist/client-plugins.d.mts +5 -5
- package/dist/client-plugins.d.ts +5 -5
- package/dist/client.cjs +6 -5
- package/dist/client.d.mts +12 -12
- package/dist/client.d.ts +12 -12
- package/dist/client.mjs +5 -4
- package/dist/config.d.mts +5 -5
- package/dist/config.d.ts +5 -5
- package/dist/cron.cjs +6 -2
- package/dist/cron.d.mts +11 -2
- package/dist/cron.d.ts +11 -2
- package/dist/cron.mjs +7 -3
- package/dist/desktop.d.mts +6 -6
- package/dist/desktop.d.ts +6 -6
- package/dist/{devtools-7JPQMSTQ.mjs → devtools-WPX62NG2.mjs} +10 -9
- package/dist/{devtools-IZFUYWPG.cjs → devtools-YMDS7PUA.cjs} +12 -11
- package/dist/docs.cjs +14 -13
- package/dist/docs.d.mts +6 -6
- package/dist/docs.d.ts +6 -6
- package/dist/docs.mjs +13 -12
- package/dist/{endpoint.d-BkMSCRf6.d.mts → endpoint.d-BXbBpKoh.d.mts} +42 -1
- package/dist/{endpoint.d-BgHn0lhl.d.ts → endpoint.d-Dx_1k6Du.d.ts} +42 -1
- package/dist/environment/vite.cjs +3 -3
- package/dist/environment/vite.mjs +2 -2
- package/dist/headers.cjs +3 -3
- package/dist/{headers.d-CqpTL_fZ.d.ts → headers.d-BIbQyAxJ.d.ts} +1 -1
- package/dist/{headers.d-rbbTKGaN.d.mts → headers.d-BtNxFc2s.d.mts} +1 -1
- package/dist/headers.mjs +2 -2
- package/dist/index.cjs +73 -60
- package/dist/{index.d-CMKvzHLW.d.ts → index.d-CQ_wUzOV.d.ts} +1 -1
- package/dist/{index.d-D_B2D9Il.d.mts → index.d-CQdDRXd1.d.mts} +1 -1
- package/dist/index.d.mts +63 -29
- package/dist/index.d.ts +63 -29
- package/dist/index.mjs +69 -56
- package/dist/integrations/orm.d.mts +5 -5
- package/dist/integrations/orm.d.ts +5 -5
- package/dist/integrations.cjs +4 -4
- package/dist/integrations.d.mts +5 -5
- package/dist/integrations.d.ts +5 -5
- package/dist/integrations.mjs +3 -3
- package/dist/internal/app-markdown-runtime.cjs +7 -3
- package/dist/internal/app-markdown-runtime.d.mts +18 -7
- package/dist/internal/app-markdown-runtime.d.ts +18 -7
- package/dist/internal/app-markdown-runtime.mjs +6 -2
- package/dist/internal/build-runtime.cjs +42 -40
- package/dist/internal/build-runtime.d.mts +7 -7
- package/dist/internal/build-runtime.d.ts +7 -7
- package/dist/internal/build-runtime.mjs +41 -39
- package/dist/internal/cli-runtime.cjs +21 -20
- package/dist/internal/cli-runtime.mjs +20 -19
- package/dist/internal/client-error-overlay.cjs +6 -6
- package/dist/internal/client-error-overlay.mjs +2 -2
- package/dist/internal/client-runtime.cjs +6 -2
- package/dist/internal/client-runtime.d.mts +22 -10
- package/dist/internal/client-runtime.d.ts +22 -10
- package/dist/internal/client-runtime.mjs +5 -1
- package/dist/internal/compression-runtime.d.mts +5 -5
- package/dist/internal/compression-runtime.d.ts +5 -5
- package/dist/internal/config-runtime.cjs +12 -11
- package/dist/internal/config-runtime.d.mts +7 -7
- package/dist/internal/config-runtime.d.ts +7 -7
- package/dist/internal/config-runtime.mjs +11 -10
- package/dist/internal/form-actions.cjs +5 -4
- package/dist/internal/form-actions.d.mts +2 -2
- package/dist/internal/form-actions.d.ts +2 -2
- package/dist/internal/form-actions.mjs +4 -3
- package/dist/internal/infra-analytics-runtime.cjs +10 -10
- package/dist/internal/infra-analytics-runtime.mjs +8 -8
- package/dist/internal/native-server-fns.cjs +4 -4
- package/dist/internal/native-server-fns.mjs +3 -3
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +32 -22
- package/dist/internal/production-runtime.d.mts +65 -14
- package/dist/internal/production-runtime.d.ts +65 -14
- package/dist/internal/production-runtime.mjs +31 -21
- package/dist/internal/react-cache.cjs +3 -3
- package/dist/internal/react-cache.mjs +1 -1
- package/dist/internal/vercel-edge-middleware.cjs +4 -4
- package/dist/internal/vercel-edge-middleware.mjs +3 -3
- package/dist/{lifecycle.d-keQs5Swc.d.mts → lifecycle.d-OtGWAvJT.d.mts} +4 -0
- package/dist/{lifecycle.d-keQs5Swc.d.ts → lifecycle.d-OtGWAvJT.d.ts} +4 -0
- package/dist/{manager-JIA66YJ2.mjs → manager-RHB2P35B.mjs} +4 -1
- package/dist/{manager-JOHU6BQI.cjs → manager-S77ZARTC.cjs} +5 -2
- package/dist/markdown.cjs +2 -2
- package/dist/markdown.d.mts +5 -5
- package/dist/markdown.d.ts +5 -5
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.cjs +6 -6
- package/dist/middleware.d.mts +5 -5
- package/dist/middleware.d.ts +5 -5
- package/dist/middleware.mjs +5 -5
- package/dist/{mount.d-ImEO7q8a.d.mts → mount.d-6bhpBQQB.d.mts} +1 -1
- package/dist/{mount.d-B0XMxDRh.d.ts → mount.d-C-u7rFkM.d.ts} +1 -1
- package/dist/{native-server-fn-handler-EP5AFJYE.mjs → native-server-fn-handler-I66X4E5S.mjs} +6 -5
- package/dist/{native-server-fn-handler-QRTXGZA4.cjs → native-server-fn-handler-W4FSD76W.cjs} +7 -6
- package/dist/{native-tree-L2IIEBXH.mjs → native-tree-3X23BT3N.mjs} +2 -2
- package/dist/{native-tree-GF4BH33L.cjs → native-tree-TAPKR7QJ.cjs} +3 -3
- package/dist/{navigation-delegate.d-83Q7ksf7.d.mts → navigation-delegate.d-nx6gtsY4.d.mts} +1 -1
- package/dist/{navigation-delegate.d-RRx1CSlb.d.ts → navigation-delegate.d-xsG4T1x-.d.ts} +1 -1
- package/dist/navigation.cjs +4 -4
- package/dist/navigation.d.mts +8 -8
- package/dist/navigation.d.ts +8 -8
- package/dist/navigation.mjs +3 -3
- package/dist/{nitro-2LMOMIST.cjs → nitro-SSFTPZMW.cjs} +4 -4
- package/dist/{nitro-72TFIGGO.mjs → nitro-XTQ2HKDL.mjs} +1 -1
- package/dist/{observability.d-B2363jB6.d.ts → observability.d-DdJRiaIX.d.mts} +27 -3
- package/dist/{observability.d-B2363jB6.d.mts → observability.d-DdJRiaIX.d.ts} +27 -3
- package/dist/observability.d.mts +1 -1
- package/dist/observability.d.ts +1 -1
- package/dist/plugin.cjs +36 -33
- package/dist/plugin.d.mts +8 -8
- package/dist/plugin.d.ts +8 -8
- package/dist/plugin.mjs +35 -32
- package/dist/query/client.cjs +5 -5
- package/dist/query/client.mjs +1 -1
- package/dist/{render-plan.d-wP8nTeRV.d.mts → render-plan.d-B5y3h97B.d.mts} +1 -1
- package/dist/{render-plan.d-Ds2sXJ5m.d.ts → render-plan.d-gW0fwKz2.d.ts} +1 -1
- package/dist/renderer-client.cjs +4 -4
- package/dist/renderer-client.d.mts +8 -8
- package/dist/renderer-client.d.ts +8 -8
- package/dist/renderer-client.mjs +1 -1
- package/dist/request.cjs +2 -2
- package/dist/{request.d-zpSn6pu_.d.ts → request.d-B0ugAadD.d.ts} +9 -2
- package/dist/{request.d-F3h7K37m.d.mts → request.d-DLq33nYo.d.mts} +9 -2
- package/dist/request.d.mts +6 -6
- package/dist/request.d.ts +6 -6
- package/dist/request.mjs +1 -1
- package/dist/{route-rendering.d-Mw0ZKG2e.d.mts → route-rendering.d-DSeIV7yV.d.mts} +1 -1
- package/dist/{route-rendering.d-BL0_AdKj.d.ts → route-rendering.d-ytaqDQD6.d.ts} +1 -1
- package/dist/{route.d-DrXkpvcg.d.mts → route.d-Cd4Fi6BA.d.ts} +3 -1
- package/dist/{route.d-hs-_cyHn.d.ts → route.d-ShmtqqVQ.d.mts} +3 -1
- package/dist/{router.d-BwXigemZ.d.ts → router.d-BaEAEGPg.d.ts} +1 -1
- package/dist/{router.d-NGVsU11T.d.mts → router.d-Chd5cpe3.d.mts} +1 -1
- package/dist/routes.cjs +5 -3
- package/dist/routes.d.mts +5 -5
- package/dist/routes.d.ts +5 -5
- package/dist/routes.mjs +4 -2
- package/dist/{rsc-pipeline-DHYZLWSF.mjs → rsc-pipeline-DPMYONEV.mjs} +12 -11
- package/dist/{rsc-pipeline-BNXYMG4G.cjs → rsc-pipeline-XIUUMMG5.cjs} +13 -12
- package/dist/{runtime-IWOT6ZVC.cjs → runtime-WD77S3C5.cjs} +25 -25
- package/dist/{runtime-XPYKUNL3.mjs → runtime-XIUJZTZ3.mjs} +16 -16
- package/dist/{runtime.d-BA3MzhXz.d.mts → runtime.d-DpCs0eAO.d.mts} +3 -3
- package/dist/{runtime.d-OBIZWpx1.d.ts → runtime.d-h2USyQsz.d.ts} +3 -3
- package/dist/server-action-security.cjs +5 -3
- package/dist/server-action-security.d.mts +11 -3
- package/dist/server-action-security.d.ts +11 -3
- package/dist/server-action-security.mjs +4 -2
- package/dist/server-fn-client.d.mts +3 -3
- package/dist/server-fn-client.d.ts +3 -3
- package/dist/server-fn.cjs +6 -5
- package/dist/server-fn.d.mts +1 -1
- package/dist/server-fn.d.ts +1 -1
- package/dist/server-fn.mjs +5 -4
- package/dist/server-plugins.cjs +4 -4
- package/dist/server-plugins.d.mts +54 -10
- package/dist/server-plugins.d.ts +54 -10
- package/dist/server-plugins.mjs +3 -3
- package/dist/server-query-client.d.mts +1 -1
- package/dist/server-query-client.d.ts +1 -1
- package/dist/server-query.cjs +7 -6
- package/dist/server-query.d.mts +1 -1
- package/dist/server-query.d.ts +1 -1
- package/dist/server-query.mjs +6 -5
- package/dist/server.cjs +65 -68
- package/dist/server.d.mts +15 -15
- package/dist/server.d.ts +15 -15
- package/dist/server.mjs +44 -47
- package/dist/{spa-router.d-BG2XzE5p.d.mts → spa-router.d-DCQVtEaE.d.mts} +11 -5
- package/dist/{spa-router.d-DrYT944-.d.ts → spa-router.d-DpdJHs1q.d.ts} +11 -5
- package/dist/testing.cjs +16 -14
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.mjs +12 -10
- package/dist/theme/server.cjs +3 -3
- package/dist/theme/server.mjs +2 -2
- package/dist/{utils.d-C1k9BJeD.d.mts → utils.d-DKDZtAY5.d.mts} +1 -1
- package/dist/{utils.d-DcF4wxey.d.ts → utils.d-DmicwMvS.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +38 -33
- package/dist/vite.d.mts +24 -10
- package/dist/vite.d.ts +24 -10
- package/dist/vite.mjs +37 -32
- package/package.json +1 -1
- package/dist/analyzer-UJG4MIZW.cjs +0 -16
- package/dist/chunk-6I4BFRE7.cjs +0 -51
- package/dist/chunk-EIVGPQN5.mjs +0 -51
- package/dist/chunk-V3UOEWCB.cjs +0 -46
- package/dist/chunk-VE3FWJBO.mjs +0 -46
- /package/dist/{chunk-QEJWNXRI.cjs → chunk-EMRYJG4U.cjs} +0 -0
- /package/dist/{chunk-TXE4SAMV.mjs → chunk-H2ZJ35NW.mjs} +0 -0
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
collectFarmNativeServerFns,
|
|
28
28
|
findFarmNativeScreenFiles
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6JEXH7N6.mjs";
|
|
30
30
|
import {
|
|
31
31
|
generateNativeMCPPluginSource
|
|
32
32
|
} from "./chunk-KQH2COEJ.mjs";
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
hasFarmDocsRuntimeAdapter,
|
|
42
42
|
listFarmDocsAdapterPages,
|
|
43
43
|
listFarmDocsPagePaths
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-AU5UPNOD.mjs";
|
|
45
45
|
import {
|
|
46
46
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
47
47
|
createFarmDocsHandler,
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
loadFarmDocsPage,
|
|
55
55
|
resolveFarmDocsContentDir,
|
|
56
56
|
toFarmDocsMarkdownPage
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-OSKIG4OP.mjs";
|
|
58
58
|
import {
|
|
59
59
|
generateFarmDocsSearchClientRuntime,
|
|
60
60
|
isFarmDocsSearchEnabled,
|
|
@@ -62,19 +62,19 @@ import {
|
|
|
62
62
|
} from "./chunk-ALEUMLJN.mjs";
|
|
63
63
|
import {
|
|
64
64
|
CDN_CACHE_CONTROL_HEADERS
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-O6K4G7YA.mjs";
|
|
66
66
|
import {
|
|
67
67
|
FARM_PRERENDER_ENV
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-B3XY6FMC.mjs";
|
|
69
69
|
import {
|
|
70
70
|
loadFarmDocsEngine
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-LRPPXKCX.mjs";
|
|
72
72
|
import {
|
|
73
73
|
getDefaultDeployOutputDir,
|
|
74
74
|
getDeployTargetForPreset,
|
|
75
75
|
hasCustomFarmRouteContext,
|
|
76
76
|
resolveDeployOutputPath
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-JZ43UD6S.mjs";
|
|
78
78
|
import {
|
|
79
79
|
resolveFarmInstrumentationFile
|
|
80
80
|
} from "./chunk-57QAQU4F.mjs";
|
|
@@ -110,20 +110,21 @@ import {
|
|
|
110
110
|
resolveFarmImageServerRuntime,
|
|
111
111
|
resolveFarmNotFoundComponentPath,
|
|
112
112
|
resolveFarmRouteRootStrategy
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-JI6N4W2I.mjs";
|
|
114
114
|
import {
|
|
115
115
|
generateFarmClientPluginEntryCode,
|
|
116
116
|
hasFarmServerRuntimePlugins,
|
|
117
117
|
loadTailwindVitePlugin
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-BIX46FTI.mjs";
|
|
119
119
|
import {
|
|
120
120
|
PluginManager
|
|
121
121
|
} from "./chunk-Z5ZZAGIH.mjs";
|
|
122
122
|
import {
|
|
123
123
|
generateFarmTypeArtifacts,
|
|
124
124
|
readRouteRenderingDirectiveFromFile,
|
|
125
|
+
resolveRouteRenderingConfig,
|
|
125
126
|
resolveRouteRenderingConfigFromFile
|
|
126
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-CF77L6RL.mjs";
|
|
127
128
|
import {
|
|
128
129
|
HOISTED_HEAD_ELEMENT,
|
|
129
130
|
appMiddlewareMayHandlePath,
|
|
@@ -136,7 +137,7 @@ import {
|
|
|
136
137
|
layoutsCanCoverSamePage,
|
|
137
138
|
routeBoundaryCoversDirectory,
|
|
138
139
|
stripRouteGroups
|
|
139
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-LHFGTR7F.mjs";
|
|
140
141
|
import {
|
|
141
142
|
FARM_NATIVE_TREE_CONTENT_TYPE
|
|
142
143
|
} from "./chunk-LLZSYFOM.mjs";
|
|
@@ -150,15 +151,15 @@ import {
|
|
|
150
151
|
listFarmBuiltInRoutePaths,
|
|
151
152
|
resolveFarmApiCatalogInput,
|
|
152
153
|
resolveFarmAppManifestInput
|
|
153
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-FEQ72ZHD.mjs";
|
|
154
155
|
import {
|
|
155
156
|
FARM_DEFAULT_MCP_PATH,
|
|
156
157
|
createFarmDefaultMCPServer,
|
|
157
158
|
farmConfigMountsMCP
|
|
158
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-R4BWNP73.mjs";
|
|
159
160
|
import {
|
|
160
161
|
isFarmPreviewDeploymentEnvironment
|
|
161
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-VFPFXMTF.mjs";
|
|
162
163
|
import {
|
|
163
164
|
FARM_NATIVE_SERVER_FN_PLUGIN
|
|
164
165
|
} from "./chunk-L4RTTTVE.mjs";
|
|
@@ -169,14 +170,17 @@ import {
|
|
|
169
170
|
enforceFarmIsolatedHydrationRouteBudget,
|
|
170
171
|
farmEnvironmentFunctionsPlugin,
|
|
171
172
|
getClientModuleHydrationPlan,
|
|
173
|
+
getClientModuleHydrationPlanKey,
|
|
172
174
|
getClientModuleMetadata,
|
|
173
175
|
getFarmClientHydrationPlanOptions,
|
|
174
176
|
resolveFarmIsolatedClientHydrationMode,
|
|
175
177
|
resolvePackageClientBoundaryCacheFile,
|
|
176
178
|
usePackageClientBoundaryCacheFile,
|
|
177
179
|
usesFarmServerTree,
|
|
180
|
+
withFarmSourceSnapshot,
|
|
181
|
+
withFarmSourceSnapshotOf,
|
|
178
182
|
withPackageClientBoundaryCache
|
|
179
|
-
} from "./chunk-
|
|
183
|
+
} from "./chunk-BFOMCSZ2.mjs";
|
|
180
184
|
import {
|
|
181
185
|
generateFarmDocsAdapterClientRuntime,
|
|
182
186
|
getFarmDocsAdapterConfigModule
|
|
@@ -213,24 +217,28 @@ import {
|
|
|
213
217
|
applyFarmCronVercelCrons,
|
|
214
218
|
createFarmCronCloudflareConfig,
|
|
215
219
|
mergeScheduledTasks,
|
|
216
|
-
prepareFarmCronForNitro
|
|
217
|
-
|
|
220
|
+
prepareFarmCronForNitro,
|
|
221
|
+
toFarmCronCloudflareScheduledTasks
|
|
222
|
+
} from "./chunk-FGXSWRWA.mjs";
|
|
218
223
|
import {
|
|
219
224
|
resolveServerActionsConfig
|
|
220
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-ZD7JUTBY.mjs";
|
|
221
226
|
import {
|
|
222
227
|
createBundledEnv
|
|
223
228
|
} from "./chunk-N33DLJBC.mjs";
|
|
224
229
|
import {
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
FARM_MARKDOWN_PRECOMPILED_PAGES,
|
|
231
|
+
isFarmMarkdownPageFile,
|
|
232
|
+
parseMarkdownFrontmatter,
|
|
233
|
+
readFarmMarkdownRouteConfig
|
|
234
|
+
} from "./chunk-R6Q6VSGU.mjs";
|
|
227
235
|
import {
|
|
228
236
|
resolveFarmMdxComponentsModulePath,
|
|
229
237
|
resolveMdxConfig
|
|
230
238
|
} from "./chunk-UIJOLBUL.mjs";
|
|
231
239
|
import {
|
|
232
240
|
getFarmMarkdownAlternatePath
|
|
233
|
-
} from "./chunk-
|
|
241
|
+
} from "./chunk-VKLV7GF4.mjs";
|
|
234
242
|
import {
|
|
235
243
|
withPlainDiagnostics
|
|
236
244
|
} from "./chunk-MGKWYPE3.mjs";
|
|
@@ -241,7 +249,7 @@ import {
|
|
|
241
249
|
import {
|
|
242
250
|
getFarmIntegrationPluginServerRuntime,
|
|
243
251
|
getIntegrationProviders
|
|
244
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-FCBUNILW.mjs";
|
|
245
253
|
import {
|
|
246
254
|
FARM_INTEGRATION_API_BASE_PATH_KEY
|
|
247
255
|
} from "./chunk-M53MIIXY.mjs";
|
|
@@ -255,7 +263,7 @@ import {
|
|
|
255
263
|
} from "./chunk-MMK4MZUN.mjs";
|
|
256
264
|
import {
|
|
257
265
|
APIRouteManager
|
|
258
|
-
} from "./chunk-
|
|
266
|
+
} from "./chunk-X2KNHD4B.mjs";
|
|
259
267
|
import {
|
|
260
268
|
readFarmI18nCatalogs
|
|
261
269
|
} from "./chunk-VO55MMBX.mjs";
|
|
@@ -283,7 +291,7 @@ import {
|
|
|
283
291
|
} from "./chunk-2I6PUKWJ.mjs";
|
|
284
292
|
import {
|
|
285
293
|
FARM_VERSION
|
|
286
|
-
} from "./chunk-
|
|
294
|
+
} from "./chunk-IG4IQMIW.mjs";
|
|
287
295
|
import {
|
|
288
296
|
getFarmPresetRuntime,
|
|
289
297
|
resolveCloudflareProcessEnvFlags
|
|
@@ -293,19 +301,21 @@ import {
|
|
|
293
301
|
} from "./chunk-4O26BPUY.mjs";
|
|
294
302
|
import {
|
|
295
303
|
_runWithFarmCspNonce
|
|
296
|
-
} from "./chunk-
|
|
304
|
+
} from "./chunk-WTTJ2YS2.mjs";
|
|
297
305
|
import {
|
|
298
306
|
applyFarmBasePath,
|
|
299
307
|
normalizeFarmBasePath,
|
|
300
308
|
stripFarmBasePath
|
|
301
309
|
} from "./chunk-SF3JB56B.mjs";
|
|
302
310
|
import {
|
|
303
|
-
compareRoutePatternSpecificity
|
|
311
|
+
compareRoutePatternSpecificity,
|
|
312
|
+
compareRouteSpecificity,
|
|
313
|
+
getRoutePatternSpecificity
|
|
304
314
|
} from "./chunk-AYP2YFVN.mjs";
|
|
305
315
|
|
|
306
316
|
// src/build/index.ts
|
|
307
|
-
import
|
|
308
|
-
import { existsSync as
|
|
317
|
+
import path16 from "path";
|
|
318
|
+
import { existsSync as existsSync4 } from "fs";
|
|
309
319
|
|
|
310
320
|
// src/nitro/universal-build.ts
|
|
311
321
|
import { randomBytes } from "crypto";
|
|
@@ -316,15 +326,15 @@ var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
|
316
326
|
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
317
327
|
var FARM_CLIENT_BOOT_SRC_PLACEHOLDER = "/__farm_client_boot_src__";
|
|
318
328
|
async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
319
|
-
const
|
|
329
|
+
const fs5 = await import("fs/promises");
|
|
320
330
|
try {
|
|
321
|
-
const bytes = await
|
|
331
|
+
const bytes = await fs5.readFile(sourcePath);
|
|
322
332
|
if (bytes.length === 0) return null;
|
|
323
333
|
const { createHash } = await import("crypto");
|
|
324
334
|
const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
325
335
|
const name = hashedName(hash);
|
|
326
|
-
await
|
|
327
|
-
await
|
|
336
|
+
await fs5.mkdir(destinationDir, { recursive: true });
|
|
337
|
+
await fs5.writeFile(path.join(destinationDir, name), bytes);
|
|
328
338
|
return name;
|
|
329
339
|
} catch {
|
|
330
340
|
return null;
|
|
@@ -339,18 +349,18 @@ async function resolveHashedClientCssHref(clientOutputDir) {
|
|
|
339
349
|
return name ? `/assets/${name}` : "/farm-client.css";
|
|
340
350
|
}
|
|
341
351
|
async function findFingerprintedClientEntry(clientOutputDir) {
|
|
342
|
-
const
|
|
352
|
+
const fs5 = await import("fs/promises");
|
|
343
353
|
try {
|
|
344
|
-
const entries = await
|
|
354
|
+
const entries = await fs5.readdir(clientOutputDir);
|
|
345
355
|
return entries.find((name) => /^farm-client-h[0-9a-f]+\.js$/.test(name)) ?? null;
|
|
346
356
|
} catch {
|
|
347
357
|
return null;
|
|
348
358
|
}
|
|
349
359
|
}
|
|
350
360
|
async function resolveClientBootSrc(clientOutputDir) {
|
|
351
|
-
const
|
|
361
|
+
const fs5 = await import("fs/promises");
|
|
352
362
|
try {
|
|
353
|
-
const entries = await
|
|
363
|
+
const entries = await fs5.readdir(clientOutputDir);
|
|
354
364
|
const name = entries.find((entry) => /^farm-client-boot-h[0-9a-f]+\.js$/.test(entry));
|
|
355
365
|
return name ? `/${name}` : null;
|
|
356
366
|
} catch {
|
|
@@ -360,17 +370,18 @@ async function resolveClientBootSrc(clientOutputDir) {
|
|
|
360
370
|
async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
361
371
|
const entryName = await findFingerprintedClientEntry(clientOutputDir);
|
|
362
372
|
if (!entryName) return "/farm-client.js";
|
|
363
|
-
const
|
|
373
|
+
const fs5 = await import("fs/promises");
|
|
364
374
|
const shim = `export * from "./${entryName}";
|
|
365
375
|
`;
|
|
366
|
-
await
|
|
376
|
+
await fs5.writeFile(path.join(clientOutputDir, "farm-client.js"), shim);
|
|
367
377
|
return `/${entryName}`;
|
|
368
378
|
}
|
|
369
379
|
|
|
370
380
|
// src/nitro/universal-build.ts
|
|
371
381
|
import os from "os";
|
|
372
|
-
import
|
|
373
|
-
import { constants as fsConstants, existsSync as
|
|
382
|
+
import path15 from "path";
|
|
383
|
+
import { constants as fsConstants, existsSync as existsSync3, readFileSync, realpathSync as realpathSync2, statSync } from "fs";
|
|
384
|
+
import { initSync as initModuleLexer, parse as lexModule } from "es-module-lexer";
|
|
374
385
|
import { fileURLToPath } from "url";
|
|
375
386
|
import { builtinModules, createRequire as createRequire2 } from "module";
|
|
376
387
|
import { isDeepStrictEqual } from "util";
|
|
@@ -633,12 +644,51 @@ async function readFarmClientModulePreloads(buildDir) {
|
|
|
633
644
|
}
|
|
634
645
|
}
|
|
635
646
|
function encodeFarmClientModulePreloads(manifest) {
|
|
636
|
-
return
|
|
647
|
+
return encodeFarmBuildJSONPlaceholder(manifest);
|
|
648
|
+
}
|
|
649
|
+
function encodeFarmBuildJSONPlaceholder(value) {
|
|
650
|
+
return JSON.stringify(JSON.stringify(value)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
637
651
|
}
|
|
638
652
|
|
|
639
|
-
// src/
|
|
653
|
+
// src/nitro/client-route-table.ts
|
|
640
654
|
import fs2 from "fs/promises";
|
|
641
655
|
import path4 from "path";
|
|
656
|
+
var FARM_CLIENT_ROUTE_TABLE_MODULE = "farm-client-routes";
|
|
657
|
+
var FARM_CLIENT_ROUTE_TABLE_FILE = "client-route-table.json";
|
|
658
|
+
var FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER = "__farm_client_route_table__";
|
|
659
|
+
function createFarmClientRouteTable(clientPages) {
|
|
660
|
+
let loaders = 0;
|
|
661
|
+
return clientPages.map((page) => ({
|
|
662
|
+
pattern: page.pattern,
|
|
663
|
+
...page.directory ? { directory: page.directory } : {},
|
|
664
|
+
pageShouldHydrate: page.pageShouldHydrate,
|
|
665
|
+
...page.docs ? { docs: true } : {},
|
|
666
|
+
...page.hasIsolatedClientBoundaries ? { hasIsolatedClientBoundaries: true } : {},
|
|
667
|
+
islandStrategy: page.islandStrategy,
|
|
668
|
+
...page.pageShouldHydrate ? { loader: loaders++ } : {}
|
|
669
|
+
}));
|
|
670
|
+
}
|
|
671
|
+
function generateFarmClientRouteTableModule(table) {
|
|
672
|
+
return `export default JSON.parse(${JSON.stringify(JSON.stringify(table))});
|
|
673
|
+
`;
|
|
674
|
+
}
|
|
675
|
+
async function writeFarmClientRouteTable(buildDir, table) {
|
|
676
|
+
await fs2.mkdir(buildDir, { recursive: true });
|
|
677
|
+
await fs2.writeFile(path4.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), JSON.stringify(table));
|
|
678
|
+
}
|
|
679
|
+
async function readFarmClientRouteTable(buildDir) {
|
|
680
|
+
try {
|
|
681
|
+
return JSON.parse(
|
|
682
|
+
await fs2.readFile(path4.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), "utf8")
|
|
683
|
+
);
|
|
684
|
+
} catch {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// src/docs/module-preloads.ts
|
|
690
|
+
import fs3 from "fs/promises";
|
|
691
|
+
import path5 from "path";
|
|
642
692
|
var FARM_DOCS_MODULE_PRELOADS_PLACEHOLDER = "__farm_docs_module_preloads__";
|
|
643
693
|
var FARM_DOCS_MODULE_PRELOADS_FILE = "docs-module-preloads.json";
|
|
644
694
|
function normalizeModuleId(id) {
|
|
@@ -674,7 +724,7 @@ function collectFarmDocsModulePreloads(bundle, options) {
|
|
|
674
724
|
return value;
|
|
675
725
|
};
|
|
676
726
|
const pages = {};
|
|
677
|
-
const root = normalizeModuleId(
|
|
727
|
+
const root = normalizeModuleId(path5.resolve(options.root));
|
|
678
728
|
for (const [moduleId, chunk] of byModule) {
|
|
679
729
|
if (!/\.mdx?$/.test(moduleId) || !moduleId.startsWith(`${root}/`)) continue;
|
|
680
730
|
const own = [...withStaticImports(chunk.fileName, /* @__PURE__ */ new Set())].filter(
|
|
@@ -702,9 +752,9 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
702
752
|
entryName: options.entryName,
|
|
703
753
|
runtimeModuleIds
|
|
704
754
|
});
|
|
705
|
-
await
|
|
706
|
-
await
|
|
707
|
-
|
|
755
|
+
await fs3.mkdir(options.buildDir, { recursive: true });
|
|
756
|
+
await fs3.writeFile(
|
|
757
|
+
path5.join(options.buildDir, FARM_DOCS_MODULE_PRELOADS_FILE),
|
|
708
758
|
JSON.stringify(manifest)
|
|
709
759
|
);
|
|
710
760
|
}
|
|
@@ -713,7 +763,7 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
713
763
|
async function readFarmDocsModulePreloads(buildDir) {
|
|
714
764
|
try {
|
|
715
765
|
return JSON.parse(
|
|
716
|
-
await
|
|
766
|
+
await fs3.readFile(path5.join(buildDir, FARM_DOCS_MODULE_PRELOADS_FILE), "utf8")
|
|
717
767
|
);
|
|
718
768
|
} catch {
|
|
719
769
|
return null;
|
|
@@ -724,10 +774,10 @@ function encodeFarmDocsModulePreloads(manifest) {
|
|
|
724
774
|
}
|
|
725
775
|
|
|
726
776
|
// src/route-runtime-manifest.ts
|
|
727
|
-
import
|
|
777
|
+
import path6 from "path";
|
|
728
778
|
var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
|
|
729
779
|
async function createFarmRouteRuntimeManifest(options) {
|
|
730
|
-
const root =
|
|
780
|
+
const root = path6.resolve(options.root || options.config.root || process.cwd());
|
|
731
781
|
const routes = [];
|
|
732
782
|
for (const [pattern, entry] of options.routeManager.getRoutes()) {
|
|
733
783
|
const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
|
|
@@ -796,10 +846,10 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
796
846
|
};
|
|
797
847
|
}
|
|
798
848
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
799
|
-
const
|
|
800
|
-
const manifestPath =
|
|
801
|
-
await
|
|
802
|
-
await
|
|
849
|
+
const fs5 = await import("fs/promises");
|
|
850
|
+
const manifestPath = path6.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
851
|
+
await fs5.mkdir(directory, { recursive: true });
|
|
852
|
+
await fs5.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
803
853
|
`);
|
|
804
854
|
return manifestPath;
|
|
805
855
|
}
|
|
@@ -835,13 +885,13 @@ function normalizeManifestSource(root, modulePath) {
|
|
|
835
885
|
const queryIndex = modulePath.indexOf("?");
|
|
836
886
|
const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
|
|
837
887
|
const query = queryIndex === -1 ? "" : modulePath.slice(queryIndex);
|
|
838
|
-
const relativePath =
|
|
888
|
+
const relativePath = path6.isAbsolute(filePath) ? path6.relative(root, filePath) : filePath;
|
|
839
889
|
return `${relativePath.replace(/\\/g, "/")}${query}`;
|
|
840
890
|
}
|
|
841
891
|
|
|
842
892
|
// src/nitro/vercel-route-runtime.ts
|
|
843
|
-
import
|
|
844
|
-
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest,
|
|
893
|
+
import path7 from "path";
|
|
894
|
+
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs5, basePath = "/") {
|
|
845
895
|
const dynamicRoutes = manifest.routes.filter(
|
|
846
896
|
(route) => route.rendering === "dynamic" && route.runtime !== "edge"
|
|
847
897
|
);
|
|
@@ -860,8 +910,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, b
|
|
|
860
910
|
group.routes.push(route);
|
|
861
911
|
groups.set(key, group);
|
|
862
912
|
}
|
|
863
|
-
const functionsDir =
|
|
864
|
-
const baseFunctionDir =
|
|
913
|
+
const functionsDir = path7.join(outputDir, "functions");
|
|
914
|
+
const baseFunctionDir = path7.join(functionsDir, "__nitro.func");
|
|
865
915
|
const destinations = /* @__PURE__ */ new Map();
|
|
866
916
|
let groupIndex = 0;
|
|
867
917
|
for (const [key, group] of groups) {
|
|
@@ -871,9 +921,9 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, b
|
|
|
871
921
|
}
|
|
872
922
|
groupIndex += 1;
|
|
873
923
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
874
|
-
const functionDir =
|
|
875
|
-
await
|
|
876
|
-
await configureVercelFunction(functionDir, group.config,
|
|
924
|
+
const functionDir = path7.join(functionsDir, `${functionName}.func`);
|
|
925
|
+
await fs5.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
926
|
+
await configureVercelFunction(functionDir, group.config, fs5);
|
|
877
927
|
destinations.set(key, `/${functionName}`);
|
|
878
928
|
}
|
|
879
929
|
const routes = [];
|
|
@@ -910,15 +960,15 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
|
|
|
910
960
|
if (!normalizedBasePath) return source || "/";
|
|
911
961
|
return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
|
|
912
962
|
}
|
|
913
|
-
async function configureVercelFunction(functionDir, config,
|
|
914
|
-
const configPath =
|
|
915
|
-
const current = JSON.parse(await
|
|
963
|
+
async function configureVercelFunction(functionDir, config, fs5) {
|
|
964
|
+
const configPath = path7.join(functionDir, ".vc-config.json");
|
|
965
|
+
const current = JSON.parse(await fs5.readFile(configPath, "utf8"));
|
|
916
966
|
const next = {
|
|
917
967
|
...current,
|
|
918
968
|
...config.regions?.length ? { regions: config.regions } : {},
|
|
919
969
|
...config.maxDuration ? { maxDuration: config.maxDuration } : {}
|
|
920
970
|
};
|
|
921
|
-
await
|
|
971
|
+
await fs5.writeFile(configPath, `${JSON.stringify(next, null, 2)}
|
|
922
972
|
`);
|
|
923
973
|
}
|
|
924
974
|
function hasVercelFunctionControls(route) {
|
|
@@ -955,7 +1005,7 @@ function escapeRegExp(value) {
|
|
|
955
1005
|
}
|
|
956
1006
|
|
|
957
1007
|
// src/nitro/immutable-assets.ts
|
|
958
|
-
import
|
|
1008
|
+
import path8 from "path";
|
|
959
1009
|
var FARM_IMMUTABLE_ASSET_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
960
1010
|
var FARM_IMMUTABLE_ASSET_MAX_AGE = 31536e3;
|
|
961
1011
|
var FARM_IMMUTABLE_ASSET_PATH_SOURCE = "^/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-(?:mobile-)?client(?:-boot)?)-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$";
|
|
@@ -990,7 +1040,7 @@ function planFarmImmutableAssets(options) {
|
|
|
990
1040
|
for (const [dir, files] of dirFiles) {
|
|
991
1041
|
if (!routeDirs.has(dir) && files.every(isImmutable)) {
|
|
992
1042
|
plan.publicAssets.push({
|
|
993
|
-
dir:
|
|
1043
|
+
dir: path8.join(options.clientOutputDir, dir),
|
|
994
1044
|
baseURL: `/${dir}`,
|
|
995
1045
|
maxAge: FARM_IMMUTABLE_ASSET_MAX_AGE
|
|
996
1046
|
});
|
|
@@ -1001,11 +1051,11 @@ function planFarmImmutableAssets(options) {
|
|
|
1001
1051
|
return plan;
|
|
1002
1052
|
}
|
|
1003
1053
|
async function listFarmClientOutputFiles(dir) {
|
|
1004
|
-
const
|
|
1005
|
-
const entries = await
|
|
1054
|
+
const fs5 = await import("fs/promises");
|
|
1055
|
+
const entries = await fs5.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
|
|
1006
1056
|
return entries.filter((entry) => entry.isFile()).map((entry) => {
|
|
1007
|
-
const relative =
|
|
1008
|
-
return `/${relative.split(
|
|
1057
|
+
const relative = path8.relative(dir, path8.join(entry.parentPath, entry.name));
|
|
1058
|
+
return `/${relative.split(path8.sep).join("/")}`;
|
|
1009
1059
|
});
|
|
1010
1060
|
}
|
|
1011
1061
|
|
|
@@ -1078,7 +1128,7 @@ function createFarmVercelCanonicalSlashRoutes(publicPaths) {
|
|
|
1078
1128
|
}
|
|
1079
1129
|
|
|
1080
1130
|
// src/nitro/ssr-public-assets.ts
|
|
1081
|
-
import
|
|
1131
|
+
import path9 from "path";
|
|
1082
1132
|
var SERVER_FILE_URL_RE = /new\s+URL\(\s*(["'`])([^"'`\\]+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
1083
1133
|
function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
1084
1134
|
if (relativeUrl.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(relativeUrl)) return null;
|
|
@@ -1087,8 +1137,8 @@ function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
|
1087
1137
|
relativePath = decodeURI(relativePath);
|
|
1088
1138
|
} catch {
|
|
1089
1139
|
}
|
|
1090
|
-
const fileName =
|
|
1091
|
-
|
|
1140
|
+
const fileName = path9.posix.normalize(
|
|
1141
|
+
path9.posix.join(path9.posix.dirname(chunkFileName), relativePath)
|
|
1092
1142
|
);
|
|
1093
1143
|
return fileName.startsWith("../") ? null : fileName;
|
|
1094
1144
|
}
|
|
@@ -1132,7 +1182,7 @@ function collectServerOnlySSRAssets(bundle) {
|
|
|
1132
1182
|
}
|
|
1133
1183
|
}
|
|
1134
1184
|
for (const fileName of serverOnly) {
|
|
1135
|
-
const name =
|
|
1185
|
+
const name = path9.posix.basename(fileName);
|
|
1136
1186
|
if (publicReferenceSources.some((source) => source.includes(name))) {
|
|
1137
1187
|
serverOnly.delete(fileName);
|
|
1138
1188
|
}
|
|
@@ -1150,7 +1200,7 @@ function assertServerReadSSRAssetsSupported(bundle, preset, root) {
|
|
|
1150
1200
|
const output = bundle[fileName];
|
|
1151
1201
|
const original = output?.type === "asset" ? output.originalFileNames?.[0] : void 0;
|
|
1152
1202
|
if (!original) return fileName;
|
|
1153
|
-
return
|
|
1203
|
+
return path9.relative(root, path9.resolve(root, original)).split(path9.sep).join("/");
|
|
1154
1204
|
});
|
|
1155
1205
|
throw new Error(
|
|
1156
1206
|
`The "${preset}" preset cannot run server code that imports ${sources.join(", ")}. Server code reads such a file from beside the server bundle, and this edge runtime deploys no such file (Cloudflare Workers and Vercel Edge also refuse to compile WebAssembly from bytes). Load it in the browser instead, from client code with the @farm.js/wasm plugin or a "?url" import, or deploy to a Node target such as node-server, bun, vercel or netlify.`
|
|
@@ -1166,7 +1216,7 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1166
1216
|
},
|
|
1167
1217
|
transform(code, id) {
|
|
1168
1218
|
if (!code.includes("import.meta.url")) return null;
|
|
1169
|
-
const chunkFileName =
|
|
1219
|
+
const chunkFileName = path9.relative(ssrOutputDir, id.split("?", 1)[0]).split(path9.sep).join("/");
|
|
1170
1220
|
if (bundle[chunkFileName]?.type !== "chunk") return null;
|
|
1171
1221
|
let changed = false;
|
|
1172
1222
|
const transformed = replaceServerFileReferences(
|
|
@@ -1194,10 +1244,10 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1194
1244
|
|
|
1195
1245
|
// src/nitro/netlify-entry.ts
|
|
1196
1246
|
import { existsSync } from "fs";
|
|
1197
|
-
import
|
|
1247
|
+
import path10 from "path";
|
|
1198
1248
|
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
1199
|
-
const entry =
|
|
1200
|
-
|
|
1249
|
+
const entry = path10.join(
|
|
1250
|
+
path10.dirname(nitroRuntimeEntry),
|
|
1201
1251
|
"..",
|
|
1202
1252
|
"presets",
|
|
1203
1253
|
"netlify",
|
|
@@ -1209,7 +1259,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
|
1209
1259
|
`[Farm.js] Could not find Nitro's Netlify function entry at ${entry}. Farm wraps it so private responses are never cached by Netlify's CDN; reinstall dependencies or report the installed Nitro version.`
|
|
1210
1260
|
);
|
|
1211
1261
|
}
|
|
1212
|
-
return entry.split(
|
|
1262
|
+
return entry.split(path10.sep).join("/");
|
|
1213
1263
|
}
|
|
1214
1264
|
function createFarmNetlifyEntry(options) {
|
|
1215
1265
|
return `
|
|
@@ -1259,7 +1309,7 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
1259
1309
|
|
|
1260
1310
|
// src/build/strip-platform-config.ts
|
|
1261
1311
|
import { realpathSync } from "fs";
|
|
1262
|
-
import
|
|
1312
|
+
import path11 from "path";
|
|
1263
1313
|
var PLATFORM_CONFIG_KEYS = /* @__PURE__ */ new Set(["desktop", "mobile"]);
|
|
1264
1314
|
var CONFIG_FACTORIES = /* @__PURE__ */ new Set(["defineConfig", "defineFarmConfig"]);
|
|
1265
1315
|
function isConfigObject(node) {
|
|
@@ -1333,11 +1383,11 @@ function realPath(file) {
|
|
|
1333
1383
|
try {
|
|
1334
1384
|
return realpathSync(file);
|
|
1335
1385
|
} catch {
|
|
1336
|
-
return
|
|
1386
|
+
return path11.resolve(file);
|
|
1337
1387
|
}
|
|
1338
1388
|
}
|
|
1339
1389
|
function farmStripPlatformConfigPlugin(configFiles) {
|
|
1340
|
-
const files = new Set(configFiles.flatMap((file) => [
|
|
1390
|
+
const files = new Set(configFiles.flatMap((file) => [path11.resolve(file), realPath(file)]));
|
|
1341
1391
|
return {
|
|
1342
1392
|
name: "farm:strip-platform-config",
|
|
1343
1393
|
// Before the TypeScript transform, so its import elision also drops imports only the
|
|
@@ -1347,9 +1397,9 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1347
1397
|
filter: { id: fileNamePattern(configFiles) },
|
|
1348
1398
|
async handler(code, id) {
|
|
1349
1399
|
const file = id.split("?", 1)[0];
|
|
1350
|
-
if (!files.has(
|
|
1400
|
+
if (!files.has(path11.resolve(file)) && !files.has(realPath(file))) return null;
|
|
1351
1401
|
const { parseAst } = await import("rolldown/parseAst");
|
|
1352
|
-
const extension =
|
|
1402
|
+
const extension = path11.extname(file).slice(1);
|
|
1353
1403
|
const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
|
|
1354
1404
|
const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
|
|
1355
1405
|
return stripped === null ? null : { code: stripped, map: null };
|
|
@@ -1358,9 +1408,62 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1358
1408
|
};
|
|
1359
1409
|
}
|
|
1360
1410
|
|
|
1411
|
+
// src/build/markdown-precompile.ts
|
|
1412
|
+
import { existsSync as existsSync2 } from "fs";
|
|
1413
|
+
import path12 from "path";
|
|
1414
|
+
import { pathToFileURL } from "url";
|
|
1415
|
+
import { Worker } from "worker_threads";
|
|
1416
|
+
var WORKER_SOURCE = `
|
|
1417
|
+
const { parentPort, workerData } = require("node:worker_threads");
|
|
1418
|
+
import(workerData.runtime).then(async ({ compileFarmMarkdownPage }) => {
|
|
1419
|
+
const pages = [];
|
|
1420
|
+
for (const body of workerData.bodies) {
|
|
1421
|
+
try {
|
|
1422
|
+
pages.push([body, await compileFarmMarkdownPage(body)]);
|
|
1423
|
+
} catch {}
|
|
1424
|
+
}
|
|
1425
|
+
parentPort.postMessage(pages);
|
|
1426
|
+
});
|
|
1427
|
+
`;
|
|
1428
|
+
function precompileFarmMarkdownPages(bodies, coreRoot) {
|
|
1429
|
+
const runtime = coreRoot ? path12.join(coreRoot, "dist", "internal", "app-markdown-runtime.mjs") : null;
|
|
1430
|
+
if (bodies.length === 0 || !runtime || !existsSync2(runtime)) {
|
|
1431
|
+
return { pages: Promise.resolve(/* @__PURE__ */ new Map()), dispose() {
|
|
1432
|
+
} };
|
|
1433
|
+
}
|
|
1434
|
+
let worker;
|
|
1435
|
+
const pages = new Promise((resolve) => {
|
|
1436
|
+
const done = (entries = []) => {
|
|
1437
|
+
worker = void 0;
|
|
1438
|
+
resolve(new Map(entries));
|
|
1439
|
+
};
|
|
1440
|
+
try {
|
|
1441
|
+
worker = new Worker(WORKER_SOURCE, {
|
|
1442
|
+
eval: true,
|
|
1443
|
+
workerData: { runtime: pathToFileURL(runtime).href, bodies: [...new Set(bodies)] }
|
|
1444
|
+
});
|
|
1445
|
+
} catch {
|
|
1446
|
+
done();
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
worker.once("message", (entries) => {
|
|
1450
|
+
void worker?.terminate();
|
|
1451
|
+
done(entries);
|
|
1452
|
+
});
|
|
1453
|
+
worker.once("error", () => done());
|
|
1454
|
+
worker.once("exit", () => done());
|
|
1455
|
+
});
|
|
1456
|
+
return {
|
|
1457
|
+
pages,
|
|
1458
|
+
dispose() {
|
|
1459
|
+
void worker?.terminate();
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1361
1464
|
// src/nitro/client-sourcemaps.ts
|
|
1362
|
-
import
|
|
1363
|
-
import
|
|
1465
|
+
import fs4 from "fs/promises";
|
|
1466
|
+
import path13 from "path";
|
|
1364
1467
|
var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
|
|
1365
1468
|
function resolveFarmClientSourcemap(sourcemap) {
|
|
1366
1469
|
return sourcemap ? "hidden" : false;
|
|
@@ -1379,11 +1482,11 @@ function createFarmPrivateClientSourcemapsPlugin(options) {
|
|
|
1379
1482
|
}
|
|
1380
1483
|
},
|
|
1381
1484
|
async writeBundle() {
|
|
1382
|
-
await
|
|
1485
|
+
await fs4.rm(options.outDir, { recursive: true, force: true });
|
|
1383
1486
|
for (const [fileName, source] of maps) {
|
|
1384
|
-
const target =
|
|
1385
|
-
await
|
|
1386
|
-
await
|
|
1487
|
+
const target = path13.join(options.outDir, fileName);
|
|
1488
|
+
await fs4.mkdir(path13.dirname(target), { recursive: true });
|
|
1489
|
+
await fs4.writeFile(target, source);
|
|
1387
1490
|
}
|
|
1388
1491
|
}
|
|
1389
1492
|
};
|
|
@@ -1465,7 +1568,7 @@ async function readMiddlewareFileConfig(filePath) {
|
|
|
1465
1568
|
|
|
1466
1569
|
// src/nitro/vercel-edge-middleware.ts
|
|
1467
1570
|
import { createRequire, isBuiltin } from "module";
|
|
1468
|
-
import
|
|
1571
|
+
import path14 from "path";
|
|
1469
1572
|
import { gzipSync } from "zlib";
|
|
1470
1573
|
var FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION = "_farm_middleware";
|
|
1471
1574
|
var FARM_VERCEL_EDGE_NOT_FOUND_PATH = "/__farm/not-found";
|
|
@@ -1519,22 +1622,22 @@ ${modules.join("\n")}
|
|
|
1519
1622
|
});
|
|
1520
1623
|
`;
|
|
1521
1624
|
}
|
|
1522
|
-
async function resolveFarmCoreDir(root,
|
|
1523
|
-
const runtimeEntry = createRequire(
|
|
1625
|
+
async function resolveFarmCoreDir(root, fs5) {
|
|
1626
|
+
const runtimeEntry = createRequire(path14.join(root, "package.json")).resolve(
|
|
1524
1627
|
"@farm.js/core/internal/vercel-edge-middleware"
|
|
1525
1628
|
);
|
|
1526
|
-
return
|
|
1629
|
+
return fs5.realpath(path14.resolve(path14.dirname(runtimeEntry), "..", ".."));
|
|
1527
1630
|
}
|
|
1528
1631
|
function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
1529
1632
|
const streamStub = "\0farm-edge-node-stream";
|
|
1530
|
-
const corePrefix = coreDir +
|
|
1633
|
+
const corePrefix = coreDir + path14.sep;
|
|
1531
1634
|
return {
|
|
1532
1635
|
name: "farm-vercel-edge-node-modules",
|
|
1533
1636
|
resolveId(source, importer) {
|
|
1534
1637
|
if (!isBuiltin(source)) return null;
|
|
1535
1638
|
const name = source.replace(/^node:/, "").split("/")[0];
|
|
1536
1639
|
if (EDGE_NODE_MODULES.has(name)) return { id: `node:${name}`, external: true };
|
|
1537
|
-
if (name === "stream" && importer &&
|
|
1640
|
+
if (name === "stream" && importer && path14.resolve(importer).startsWith(corePrefix)) {
|
|
1538
1641
|
return streamStub;
|
|
1539
1642
|
}
|
|
1540
1643
|
unsupported.add(`${source} (imported by ${importer ?? "the entry"})`);
|
|
@@ -1547,20 +1650,20 @@ function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
|
1547
1650
|
};
|
|
1548
1651
|
}
|
|
1549
1652
|
async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
1550
|
-
const { root, outputDir, buildDir, config, routes, guardedPages, fs:
|
|
1551
|
-
const functionDir =
|
|
1653
|
+
const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs5 } = options;
|
|
1654
|
+
const functionDir = path14.join(
|
|
1552
1655
|
outputDir,
|
|
1553
1656
|
"functions",
|
|
1554
1657
|
`${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
|
|
1555
1658
|
);
|
|
1556
|
-
const entryPath =
|
|
1557
|
-
await
|
|
1558
|
-
await
|
|
1659
|
+
const entryPath = path14.join(buildDir, "vercel-edge-middleware-entry.mjs");
|
|
1660
|
+
await fs5.mkdir(path14.dirname(entryPath), { recursive: true });
|
|
1661
|
+
await fs5.writeFile(
|
|
1559
1662
|
entryPath,
|
|
1560
1663
|
generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
|
|
1561
1664
|
);
|
|
1562
1665
|
const unsupported = /* @__PURE__ */ new Set();
|
|
1563
|
-
const coreDir = await resolveFarmCoreDir(root,
|
|
1666
|
+
const coreDir = await resolveFarmCoreDir(root, fs5);
|
|
1564
1667
|
const { rolldown } = await import("rolldown");
|
|
1565
1668
|
let code;
|
|
1566
1669
|
try {
|
|
@@ -1592,7 +1695,7 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
|
1592
1695
|
} catch (error) {
|
|
1593
1696
|
throw withPlainDiagnostics(error);
|
|
1594
1697
|
} finally {
|
|
1595
|
-
await
|
|
1698
|
+
await fs5.rm(entryPath, { force: true });
|
|
1596
1699
|
}
|
|
1597
1700
|
if (unsupported.size > 0) {
|
|
1598
1701
|
throw new Error(
|
|
@@ -1601,11 +1704,11 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
|
1601
1704
|
Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(", ")}), or remove runtime: "edge" so the middleware runs in the server and its pages render on request.`
|
|
1602
1705
|
);
|
|
1603
1706
|
}
|
|
1604
|
-
await
|
|
1605
|
-
await
|
|
1606
|
-
await
|
|
1607
|
-
await
|
|
1608
|
-
|
|
1707
|
+
await fs5.rm(functionDir, { recursive: true, force: true });
|
|
1708
|
+
await fs5.mkdir(functionDir, { recursive: true });
|
|
1709
|
+
await fs5.writeFile(path14.join(functionDir, "index.js"), code);
|
|
1710
|
+
await fs5.writeFile(
|
|
1711
|
+
path14.join(functionDir, ".vc-config.json"),
|
|
1609
1712
|
`${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
|
|
1610
1713
|
`
|
|
1611
1714
|
);
|
|
@@ -1623,11 +1726,11 @@ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(",
|
|
|
1623
1726
|
// src/nitro/universal-build.ts
|
|
1624
1727
|
var FARM_NATIVE_STYLESHEETS_PLACEHOLDER = "__FARM_NATIVE_STYLESHEETS__";
|
|
1625
1728
|
async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
|
|
1626
|
-
const
|
|
1729
|
+
const fs5 = await import("fs/promises");
|
|
1627
1730
|
try {
|
|
1628
1731
|
return {
|
|
1629
|
-
[clientCssHref]: await
|
|
1630
|
-
|
|
1732
|
+
[clientCssHref]: await fs5.readFile(
|
|
1733
|
+
path15.join(clientOutputDir, clientCssHref.slice(1)),
|
|
1631
1734
|
"utf8"
|
|
1632
1735
|
)
|
|
1633
1736
|
};
|
|
@@ -1642,18 +1745,18 @@ function preloadFarmNitroBuilder() {
|
|
|
1642
1745
|
);
|
|
1643
1746
|
}
|
|
1644
1747
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
1645
|
-
var _dirname =
|
|
1748
|
+
var _dirname = path15.dirname(_filename);
|
|
1646
1749
|
function findFarmCoreRoot(from) {
|
|
1647
|
-
let dir =
|
|
1648
|
-
while (dir !==
|
|
1649
|
-
const manifest =
|
|
1650
|
-
if (
|
|
1750
|
+
let dir = path15.dirname(from);
|
|
1751
|
+
while (dir !== path15.dirname(dir)) {
|
|
1752
|
+
const manifest = path15.join(dir, "package.json");
|
|
1753
|
+
if (existsSync3(manifest)) {
|
|
1651
1754
|
try {
|
|
1652
1755
|
if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1653
1756
|
} catch {
|
|
1654
1757
|
}
|
|
1655
1758
|
}
|
|
1656
|
-
dir =
|
|
1759
|
+
dir = path15.dirname(dir);
|
|
1657
1760
|
}
|
|
1658
1761
|
return null;
|
|
1659
1762
|
}
|
|
@@ -1663,16 +1766,16 @@ function toModulePath(file) {
|
|
|
1663
1766
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1664
1767
|
}
|
|
1665
1768
|
function findInstalledPackageDir(name, from) {
|
|
1666
|
-
for (let dir = from; ; dir =
|
|
1667
|
-
const candidate =
|
|
1668
|
-
if (
|
|
1769
|
+
for (let dir = from; ; dir = path15.dirname(dir)) {
|
|
1770
|
+
const candidate = path15.join(dir, "node_modules", name);
|
|
1771
|
+
if (existsSync3(path15.join(candidate, "package.json"))) {
|
|
1669
1772
|
try {
|
|
1670
1773
|
return realpathSync2(candidate);
|
|
1671
1774
|
} catch {
|
|
1672
1775
|
return null;
|
|
1673
1776
|
}
|
|
1674
1777
|
}
|
|
1675
|
-
if (dir ===
|
|
1778
|
+
if (dir === path15.dirname(dir)) return null;
|
|
1676
1779
|
}
|
|
1677
1780
|
}
|
|
1678
1781
|
function collectFarmDependencyDirs(root) {
|
|
@@ -1683,7 +1786,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1683
1786
|
seen.add(dir);
|
|
1684
1787
|
let manifest;
|
|
1685
1788
|
try {
|
|
1686
|
-
manifest = JSON.parse(readFileSync(
|
|
1789
|
+
manifest = JSON.parse(readFileSync(path15.join(dir, "package.json"), "utf8"));
|
|
1687
1790
|
} catch {
|
|
1688
1791
|
return;
|
|
1689
1792
|
}
|
|
@@ -1694,7 +1797,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1694
1797
|
if (farmCoreRoot) visit(realpathSync2(farmCoreRoot));
|
|
1695
1798
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1696
1799
|
try {
|
|
1697
|
-
const manifest = JSON.parse(readFileSync(
|
|
1800
|
+
const manifest = JSON.parse(readFileSync(path15.join(root, "package.json"), "utf8"));
|
|
1698
1801
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1699
1802
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1700
1803
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1761,17 +1864,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1761
1864
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1762
1865
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1763
1866
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1764
|
-
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
1867
|
+
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path15.sep).join("/");
|
|
1765
1868
|
}
|
|
1766
1869
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1767
1870
|
const nitroEntry = resolveNitroPackageEntry(root);
|
|
1768
|
-
const runtimeDir =
|
|
1871
|
+
const runtimeDir = path15.dirname(nitroEntry);
|
|
1769
1872
|
const nitroRequire = createRequire2(nitroEntry);
|
|
1770
1873
|
return {
|
|
1771
1874
|
...Object.fromEntries(
|
|
1772
1875
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1773
1876
|
`#nitro/runtime/${moduleName}`,
|
|
1774
|
-
|
|
1877
|
+
path15.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path15.sep).join("/")
|
|
1775
1878
|
])
|
|
1776
1879
|
),
|
|
1777
1880
|
// Farm's generated workflow and cron wrappers live under `.farm/` and
|
|
@@ -1780,18 +1883,31 @@ function resolveNitroInternalRuntimeAliases(root) {
|
|
|
1780
1883
|
...Object.fromEntries(
|
|
1781
1884
|
["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
|
|
1782
1885
|
specifier,
|
|
1783
|
-
nitroRequire.resolve(specifier).split(
|
|
1886
|
+
nitroRequire.resolve(specifier).split(path15.sep).join("/")
|
|
1784
1887
|
])
|
|
1785
1888
|
)
|
|
1786
1889
|
};
|
|
1787
1890
|
}
|
|
1891
|
+
function createPrerenderMarkdownPagesPlugin(pages) {
|
|
1892
|
+
return {
|
|
1893
|
+
name: "farm-prerender-markdown-pages",
|
|
1894
|
+
async banner(chunk) {
|
|
1895
|
+
if (!chunk.isEntry) return "";
|
|
1896
|
+
const compiled = await pages;
|
|
1897
|
+
if (compiled.size === 0) return "";
|
|
1898
|
+
return `globalThis[Symbol.for(${JSON.stringify(
|
|
1899
|
+
FARM_MARKDOWN_PRECOMPILED_PAGES.description
|
|
1900
|
+
)})] = new Map(${JSON.stringify([...compiled])});`;
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1788
1904
|
function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveNitroPackageEntry) {
|
|
1789
1905
|
let nitroEntry;
|
|
1790
1906
|
return {
|
|
1791
1907
|
name: "farm-prerender-runtime-resolver",
|
|
1792
1908
|
async resolveId(id, _importer, options) {
|
|
1793
1909
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1794
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
1910
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path15.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1795
1911
|
return null;
|
|
1796
1912
|
}
|
|
1797
1913
|
if (nitroEntry === void 0) {
|
|
@@ -1814,7 +1930,7 @@ function createFarmStorageModuleRegistration(config) {
|
|
|
1814
1930
|
const modules = _collectFarmStorageModules(config.storage);
|
|
1815
1931
|
if (modules.length === 0) return "";
|
|
1816
1932
|
const root = config.root || process.cwd();
|
|
1817
|
-
const projectRequire = createRequire2(
|
|
1933
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
1818
1934
|
let runtimeRequire = projectRequire;
|
|
1819
1935
|
try {
|
|
1820
1936
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1841,7 +1957,7 @@ ${loaders.join("\n")}
|
|
|
1841
1957
|
});` : "";
|
|
1842
1958
|
}
|
|
1843
1959
|
function resolveNitroPackageEntry(root) {
|
|
1844
|
-
const projectRequire = createRequire2(
|
|
1960
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
1845
1961
|
let runtimeRequire = projectRequire;
|
|
1846
1962
|
try {
|
|
1847
1963
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1911,7 +2027,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1911
2027
|
}
|
|
1912
2028
|
function hasReactDomEdgeServerBuild(root) {
|
|
1913
2029
|
try {
|
|
1914
|
-
createRequire2(
|
|
2030
|
+
createRequire2(path15.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1915
2031
|
return true;
|
|
1916
2032
|
} catch {
|
|
1917
2033
|
return false;
|
|
@@ -1942,17 +2058,17 @@ function isNitroRollupExternal(id) {
|
|
|
1942
2058
|
var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
|
|
1943
2059
|
var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
|
|
1944
2060
|
function isFarmCoreModule(file) {
|
|
1945
|
-
let dir =
|
|
1946
|
-
while (dir !==
|
|
1947
|
-
const manifest =
|
|
1948
|
-
if (
|
|
2061
|
+
let dir = path15.dirname(file.split("?", 1)[0]);
|
|
2062
|
+
while (dir !== path15.dirname(dir)) {
|
|
2063
|
+
const manifest = path15.join(dir, "package.json");
|
|
2064
|
+
if (existsSync3(manifest)) {
|
|
1949
2065
|
try {
|
|
1950
2066
|
return JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core";
|
|
1951
2067
|
} catch {
|
|
1952
2068
|
return false;
|
|
1953
2069
|
}
|
|
1954
2070
|
}
|
|
1955
|
-
dir =
|
|
2071
|
+
dir = path15.dirname(dir);
|
|
1956
2072
|
}
|
|
1957
2073
|
return false;
|
|
1958
2074
|
}
|
|
@@ -1963,7 +2079,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
|
|
|
1963
2079
|
filter: { id: exactIdPattern(["@vercel/og"]) },
|
|
1964
2080
|
handler(source, importer) {
|
|
1965
2081
|
if (source !== "@vercel/og") return null;
|
|
1966
|
-
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(
|
|
2082
|
+
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path15.basename(importer.split("?", 1)[0]));
|
|
1967
2083
|
if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
|
|
1968
2084
|
return externalizeOtherImports ? { id: source, external: true } : null;
|
|
1969
2085
|
}
|
|
@@ -1984,14 +2100,14 @@ export class ImageResponse {
|
|
|
1984
2100
|
};
|
|
1985
2101
|
}
|
|
1986
2102
|
function readVercelOgManifest(file) {
|
|
1987
|
-
let dir =
|
|
1988
|
-
while (dir !==
|
|
1989
|
-
const manifestPath =
|
|
1990
|
-
if (
|
|
2103
|
+
let dir = path15.dirname(file.split("?", 1)[0]);
|
|
2104
|
+
while (dir !== path15.dirname(dir)) {
|
|
2105
|
+
const manifestPath = path15.join(dir, "package.json");
|
|
2106
|
+
if (existsSync3(manifestPath)) {
|
|
1991
2107
|
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
1992
2108
|
return manifest.name === "@vercel/og" ? { dir, manifest } : null;
|
|
1993
2109
|
}
|
|
1994
|
-
dir =
|
|
2110
|
+
dir = path15.dirname(dir);
|
|
1995
2111
|
}
|
|
1996
2112
|
return null;
|
|
1997
2113
|
}
|
|
@@ -1999,7 +2115,7 @@ function resolveVercelOgConditionEntry(resolvedId, condition) {
|
|
|
1999
2115
|
const vercelOg = readVercelOgManifest(resolvedId);
|
|
2000
2116
|
const entry = vercelOg?.manifest.exports?.["."]?.[condition];
|
|
2001
2117
|
const file = typeof entry === "string" ? entry : entry?.default;
|
|
2002
|
-
return vercelOg && typeof file === "string" ?
|
|
2118
|
+
return vercelOg && typeof file === "string" ? path15.join(vercelOg.dir, file) : null;
|
|
2003
2119
|
}
|
|
2004
2120
|
function createEdgeMetadataImageRuntimePlugin({
|
|
2005
2121
|
condition,
|
|
@@ -2017,7 +2133,7 @@ function createEdgeMetadataImageRuntimePlugin({
|
|
|
2017
2133
|
if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
|
|
2018
2134
|
return null;
|
|
2019
2135
|
}
|
|
2020
|
-
const resolvedPath =
|
|
2136
|
+
const resolvedPath = path15.resolve(path15.dirname(importer.split("?", 1)[0]), source);
|
|
2021
2137
|
return { id: toPosixPath(resolvedPath), external: "absolute" };
|
|
2022
2138
|
}
|
|
2023
2139
|
};
|
|
@@ -2032,7 +2148,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
|
|
|
2032
2148
|
return null;
|
|
2033
2149
|
}
|
|
2034
2150
|
const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
|
|
2035
|
-
const encoded = readFileSync(
|
|
2151
|
+
const encoded = readFileSync(path15.resolve(path15.dirname(file), request)).toString("base64");
|
|
2036
2152
|
return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
|
|
2037
2153
|
});
|
|
2038
2154
|
if (inlined !== code) return { code: inlined, map: null };
|
|
@@ -2051,7 +2167,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
2051
2167
|
return null;
|
|
2052
2168
|
}
|
|
2053
2169
|
const requestPath = source.slice(0, -"?module".length);
|
|
2054
|
-
const resolvedPath =
|
|
2170
|
+
const resolvedPath = path15.isAbsolute(requestPath) ? requestPath : path15.resolve(path15.dirname(importer.split("?", 1)[0]), requestPath);
|
|
2055
2171
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
2056
2172
|
},
|
|
2057
2173
|
load(id) {
|
|
@@ -2076,11 +2192,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2076
2192
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
2077
2193
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
2078
2194
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
2079
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
2195
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path15.posix.normalize(path15.posix.join(path15.posix.dirname(fileName), normalizedImportId)) : null;
|
|
2080
2196
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
2081
2197
|
continue;
|
|
2082
2198
|
}
|
|
2083
|
-
if (
|
|
2199
|
+
if (path15.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
2084
2200
|
externalPackages.add(importId);
|
|
2085
2201
|
continue;
|
|
2086
2202
|
}
|
|
@@ -2092,15 +2208,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2092
2208
|
return externalPackages;
|
|
2093
2209
|
}
|
|
2094
2210
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
2095
|
-
const resolvedNitroEntry =
|
|
2096
|
-
const resolvedSSREntry =
|
|
2211
|
+
const resolvedNitroEntry = path15.resolve(nitroEntryPath);
|
|
2212
|
+
const resolvedSSREntry = path15.resolve(ssrOutputDir, ssrEntryFile);
|
|
2097
2213
|
return {
|
|
2098
2214
|
name: "farm-externalize-prebuilt-ssr",
|
|
2099
2215
|
resolveId(source, importer) {
|
|
2100
|
-
if (!importer ||
|
|
2216
|
+
if (!importer || path15.resolve(importer) !== resolvedNitroEntry) {
|
|
2101
2217
|
return null;
|
|
2102
2218
|
}
|
|
2103
|
-
const resolvedImport =
|
|
2219
|
+
const resolvedImport = path15.resolve(path15.dirname(importer), source);
|
|
2104
2220
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
2105
2221
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
2106
2222
|
}
|
|
@@ -2149,37 +2265,42 @@ async function minifyFarmServerChunk(code, fileName, options) {
|
|
|
2149
2265
|
}
|
|
2150
2266
|
return restoreLiteralModuleSpecifiers(result.code, fileName, rolldownUtils);
|
|
2151
2267
|
}
|
|
2268
|
+
var moduleLexerReady = false;
|
|
2269
|
+
function lexDynamicImportArguments(code) {
|
|
2270
|
+
if (!moduleLexerReady) {
|
|
2271
|
+
initModuleLexer();
|
|
2272
|
+
moduleLexerReady = true;
|
|
2273
|
+
}
|
|
2274
|
+
try {
|
|
2275
|
+
return lexModule(code)[0].filter((entry) => entry.d > -1).map((entry) => ({ start: entry.s, end: entry.e }));
|
|
2276
|
+
} catch {
|
|
2277
|
+
return null;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2152
2280
|
function restoreLiteralModuleSpecifiers(code, fileName, { parseSync, Visitor }) {
|
|
2153
2281
|
const hasImportTemplate = code.includes("import(`");
|
|
2154
2282
|
const hasRequireTemplate = code.includes("require(`");
|
|
2155
2283
|
if (!hasImportTemplate && !hasRequireTemplate) return code;
|
|
2156
|
-
const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
|
|
2157
|
-
if (parsed.errors.length > 0) {
|
|
2158
|
-
throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
|
|
2159
|
-
}
|
|
2160
2284
|
const replacements = [];
|
|
2161
2285
|
let needsAst = hasRequireTemplate && /(?<![\w$])require\(`/.test(code);
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
}
|
|
2174
|
-
replacements.push({
|
|
2175
|
-
start: moduleRequest.start,
|
|
2176
|
-
end: moduleRequest.end,
|
|
2177
|
-
text: toAsciiStringLiteral(value)
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2286
|
+
const dynamicImports = needsAst ? null : lexDynamicImportArguments(code);
|
|
2287
|
+
if (!dynamicImports) needsAst = true;
|
|
2288
|
+
for (const { start, end } of dynamicImports ?? []) {
|
|
2289
|
+
const source = code.slice(start, end);
|
|
2290
|
+
if (!source.startsWith("`")) continue;
|
|
2291
|
+
const value = source.slice(1, -1);
|
|
2292
|
+
if (source.length < 2 || !source.endsWith("`") || /[\\\r\n`]|\$\{/.test(value)) {
|
|
2293
|
+
needsAst = true;
|
|
2294
|
+
break;
|
|
2295
|
+
}
|
|
2296
|
+
replacements.push({ start, end, text: toAsciiStringLiteral(value) });
|
|
2180
2297
|
}
|
|
2181
2298
|
if (needsAst) {
|
|
2182
2299
|
replacements.length = 0;
|
|
2300
|
+
const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
|
|
2301
|
+
if (parsed.errors.length > 0) {
|
|
2302
|
+
throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
|
|
2303
|
+
}
|
|
2183
2304
|
const restore = (node) => {
|
|
2184
2305
|
if (node?.type !== "TemplateLiteral") return;
|
|
2185
2306
|
const template = node;
|
|
@@ -2233,14 +2354,14 @@ function trimSlashes(value) {
|
|
|
2233
2354
|
function resolveBuildDocsContentDir(docs, root, srcDir) {
|
|
2234
2355
|
const configuredContentDir = docs.contentDir || docs.config.contentDir;
|
|
2235
2356
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
2236
|
-
const contentDir =
|
|
2237
|
-
return
|
|
2357
|
+
const contentDir = path15.isAbsolute(configuredContentDir) ? configuredContentDir : path15.join(root, configuredContentDir);
|
|
2358
|
+
return existsSync3(contentDir) ? contentDir : null;
|
|
2238
2359
|
}
|
|
2239
2360
|
const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
|
|
2240
|
-
const appDocsDir =
|
|
2241
|
-
if (
|
|
2242
|
-
const rootDocsDir =
|
|
2243
|
-
return
|
|
2361
|
+
const appDocsDir = path15.join(root, srcDir || "src", "app", entryDir);
|
|
2362
|
+
if (existsSync3(appDocsDir)) return appDocsDir;
|
|
2363
|
+
const rootDocsDir = path15.join(root, entryDir);
|
|
2364
|
+
return existsSync3(rootDocsDir) ? rootDocsDir : null;
|
|
2244
2365
|
}
|
|
2245
2366
|
function hasProjectPostcssConfig(root) {
|
|
2246
2367
|
const candidates = [
|
|
@@ -2256,7 +2377,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2256
2377
|
".postcssrc.mjs",
|
|
2257
2378
|
".postcssrc.ts"
|
|
2258
2379
|
];
|
|
2259
|
-
const projectRequire = createRequire2(
|
|
2380
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
2260
2381
|
return candidates.some((file) => {
|
|
2261
2382
|
try {
|
|
2262
2383
|
projectRequire.resolve(`./${file}`);
|
|
@@ -2267,7 +2388,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2267
2388
|
});
|
|
2268
2389
|
}
|
|
2269
2390
|
async function findFarmConfigPath(root) {
|
|
2270
|
-
const
|
|
2391
|
+
const fs5 = await import("fs/promises");
|
|
2271
2392
|
const candidates = [
|
|
2272
2393
|
"farm.config.ts",
|
|
2273
2394
|
"farm.config.mts",
|
|
@@ -2279,9 +2400,9 @@ async function findFarmConfigPath(root) {
|
|
|
2279
2400
|
"config.mjs"
|
|
2280
2401
|
];
|
|
2281
2402
|
for (const candidate of candidates) {
|
|
2282
|
-
const resolvedPath =
|
|
2403
|
+
const resolvedPath = path15.join(root, candidate);
|
|
2283
2404
|
try {
|
|
2284
|
-
await
|
|
2405
|
+
await fs5.access(resolvedPath);
|
|
2285
2406
|
return resolvedPath;
|
|
2286
2407
|
} catch {
|
|
2287
2408
|
}
|
|
@@ -2299,13 +2420,13 @@ function farmServerRuntimePluginsMayHandlePath(config, pathname) {
|
|
|
2299
2420
|
);
|
|
2300
2421
|
}
|
|
2301
2422
|
async function discoverMiddlewareRoutes(appDir) {
|
|
2302
|
-
const
|
|
2423
|
+
const fs5 = await import("fs/promises");
|
|
2303
2424
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
2304
2425
|
const routes = /* @__PURE__ */ new Map();
|
|
2305
2426
|
async function walk(dir, routePath, directory, discovered) {
|
|
2306
2427
|
let entries;
|
|
2307
2428
|
try {
|
|
2308
|
-
entries = await
|
|
2429
|
+
entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
2309
2430
|
} catch {
|
|
2310
2431
|
return;
|
|
2311
2432
|
}
|
|
@@ -2316,7 +2437,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2316
2437
|
discovered.push({
|
|
2317
2438
|
path: routePath,
|
|
2318
2439
|
directory,
|
|
2319
|
-
filePath:
|
|
2440
|
+
filePath: path15.join(dir, middlewareFile.name)
|
|
2320
2441
|
});
|
|
2321
2442
|
}
|
|
2322
2443
|
for (const entry of entries) {
|
|
@@ -2324,7 +2445,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2324
2445
|
continue;
|
|
2325
2446
|
}
|
|
2326
2447
|
await walk(
|
|
2327
|
-
|
|
2448
|
+
path15.join(dir, entry.name),
|
|
2328
2449
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
2329
2450
|
appendMiddlewareDirectory(directory, entry.name),
|
|
2330
2451
|
discovered
|
|
@@ -2362,6 +2483,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2362
2483
|
logger.info(`\u{1F69C} Building Farm.js application (universal) with preset: ${preset}...`);
|
|
2363
2484
|
const rendererBuild = options.rendererBuildLifetime ? void 0 : new AbortController();
|
|
2364
2485
|
const rendererBuildLifetime = options.rendererBuildLifetime ?? rendererBuild.signal;
|
|
2486
|
+
let markdownPrecompile;
|
|
2365
2487
|
try {
|
|
2366
2488
|
const routeRuntimeManifestPromise = options.routeRuntimeManifest ? Promise.resolve(options.routeRuntimeManifest) : createFarmRouteRuntimeManifest({
|
|
2367
2489
|
config,
|
|
@@ -2383,6 +2505,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2383
2505
|
} : {}
|
|
2384
2506
|
});
|
|
2385
2507
|
}
|
|
2508
|
+
markdownPrecompile = precompileFarmMarkdownPages(
|
|
2509
|
+
collectFarmPrerenderedMarkdownBodies(pageRoutes),
|
|
2510
|
+
farmCoreRoot
|
|
2511
|
+
);
|
|
2386
2512
|
const routeSlots = Array.from(
|
|
2387
2513
|
routeManager.getRouteSlots().values(),
|
|
2388
2514
|
(entry) => ({
|
|
@@ -2397,21 +2523,21 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2397
2523
|
})
|
|
2398
2524
|
);
|
|
2399
2525
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
2400
|
-
const
|
|
2526
|
+
const fs5 = await import("fs/promises");
|
|
2401
2527
|
const layoutRoutes = [];
|
|
2402
|
-
const appDir =
|
|
2528
|
+
const appDir = path15.join(root, srcDir, "app");
|
|
2403
2529
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
2404
2530
|
try {
|
|
2405
|
-
const entries = await
|
|
2531
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
2406
2532
|
for (const entry of entries) {
|
|
2407
2533
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
2408
2534
|
layoutRoutes.push({
|
|
2409
2535
|
pattern: routePrefix,
|
|
2410
|
-
modulePath:
|
|
2536
|
+
modulePath: path15.join(dir, entry.name)
|
|
2411
2537
|
});
|
|
2412
2538
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
2413
2539
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
2414
|
-
await findLayoutsForClient(
|
|
2540
|
+
await findLayoutsForClient(path15.join(dir, entry.name), childPrefix);
|
|
2415
2541
|
}
|
|
2416
2542
|
}
|
|
2417
2543
|
} catch {
|
|
@@ -2434,8 +2560,9 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2434
2560
|
${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
2435
2561
|
);
|
|
2436
2562
|
}
|
|
2437
|
-
const hydrationPlanCache =
|
|
2438
|
-
const
|
|
2563
|
+
const hydrationPlanCache = routeManager.getRouteModuleHydrationPlans();
|
|
2564
|
+
const sourceSnapshot = routeManager.takeBuildSourceSnapshot();
|
|
2565
|
+
const clientOutputDir = path15.join(root, distDir, "client");
|
|
2439
2566
|
const [productionViteResult] = await productionViteResultPromise;
|
|
2440
2567
|
if (productionViteResult.status === "rejected") {
|
|
2441
2568
|
await routeRuntimeManifestResultPromise;
|
|
@@ -2447,8 +2574,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2447
2574
|
const rendererDisabled = isFarmRendererDisabled(config.renderer);
|
|
2448
2575
|
const buildClientBundle = async () => {
|
|
2449
2576
|
if (rendererDisabled) {
|
|
2450
|
-
await
|
|
2451
|
-
await
|
|
2577
|
+
await fs5.rm(clientOutputDir, { recursive: true, force: true });
|
|
2578
|
+
await fs5.mkdir(clientOutputDir, { recursive: true });
|
|
2452
2579
|
return;
|
|
2453
2580
|
}
|
|
2454
2581
|
return buildClient(
|
|
@@ -2464,7 +2591,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2464
2591
|
hydrationPlanCache,
|
|
2465
2592
|
rendererBuildLifetime,
|
|
2466
2593
|
routeManager.getProgrammaticClientRoutes(),
|
|
2467
|
-
mobileClient
|
|
2594
|
+
mobileClient,
|
|
2595
|
+
sourceSnapshot
|
|
2468
2596
|
);
|
|
2469
2597
|
};
|
|
2470
2598
|
const buildSSRBundle = () => buildSSRInMemory(
|
|
@@ -2480,7 +2608,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2480
2608
|
routeSlots,
|
|
2481
2609
|
isolatedClientBoundaryModules,
|
|
2482
2610
|
hydrationPlanCache,
|
|
2483
|
-
rendererBuildLifetime
|
|
2611
|
+
rendererBuildLifetime,
|
|
2612
|
+
sourceSnapshot
|
|
2484
2613
|
);
|
|
2485
2614
|
let clientBuildResult;
|
|
2486
2615
|
let ssrBuildResult;
|
|
@@ -2521,7 +2650,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2521
2650
|
hydrationPlanCache,
|
|
2522
2651
|
rendererBuildLifetime,
|
|
2523
2652
|
routeManager.getProgrammaticClientRoutes(),
|
|
2524
|
-
mobileClient
|
|
2653
|
+
mobileClient,
|
|
2654
|
+
sourceSnapshot
|
|
2525
2655
|
);
|
|
2526
2656
|
} catch (retryError) {
|
|
2527
2657
|
if (!(retryError instanceof IncompleteClientBuildOutputError)) throw retryError;
|
|
@@ -2530,6 +2660,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2530
2660
|
);
|
|
2531
2661
|
}
|
|
2532
2662
|
}
|
|
2663
|
+
sourceSnapshot?.clear();
|
|
2533
2664
|
const ssrResult = ssrBuildResult.value;
|
|
2534
2665
|
const routeRuntimeManifest = routeRuntimeManifestResult.value;
|
|
2535
2666
|
const runtimeValidation = validateFarmRouteRuntimeDeployment(routeRuntimeManifest, preset);
|
|
@@ -2557,13 +2688,14 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2557
2688
|
routeRuntimeManifest,
|
|
2558
2689
|
configuredHeaderRoutes,
|
|
2559
2690
|
nitroBuilderResultPromise,
|
|
2560
|
-
lifecyclePluginManager
|
|
2691
|
+
lifecyclePluginManager,
|
|
2692
|
+
markdownPrecompile?.pages
|
|
2561
2693
|
);
|
|
2562
2694
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
2563
|
-
|
|
2695
|
+
path15.join(root, distDir),
|
|
2564
2696
|
routeRuntimeManifest
|
|
2565
2697
|
);
|
|
2566
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
2698
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path15.relative(root, runtimeManifestPath)}`);
|
|
2567
2699
|
} catch (error) {
|
|
2568
2700
|
if (lifecyclePluginManager) {
|
|
2569
2701
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -2579,7 +2711,21 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2579
2711
|
throw error;
|
|
2580
2712
|
} finally {
|
|
2581
2713
|
rendererBuild?.abort();
|
|
2714
|
+
markdownPrecompile?.dispose();
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
function collectFarmPrerenderedMarkdownBodies(pageRoutes) {
|
|
2718
|
+
const bodies = [];
|
|
2719
|
+
for (const route of pageRoutes) {
|
|
2720
|
+
if (route.source === void 0 || !isFarmMarkdownPageFile(route.modulePath)) continue;
|
|
2721
|
+
const { body } = parseMarkdownFrontmatter(route.source);
|
|
2722
|
+
const rendering = resolveRouteRenderingConfig(
|
|
2723
|
+
readFarmMarkdownRouteConfig(body),
|
|
2724
|
+
route.source
|
|
2725
|
+
);
|
|
2726
|
+
if (rendering.ssg && rendering.revalidate === void 0) bodies.push(body);
|
|
2582
2727
|
}
|
|
2728
|
+
return bodies;
|
|
2583
2729
|
}
|
|
2584
2730
|
function shouldBuildFarmMobileClient(config) {
|
|
2585
2731
|
return Boolean(config.mobileClient) && !config.desktop;
|
|
@@ -2599,7 +2745,7 @@ function varyFarmNitroCacheRules(rules, headerNames) {
|
|
|
2599
2745
|
);
|
|
2600
2746
|
}
|
|
2601
2747
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
2602
|
-
const
|
|
2748
|
+
const fs5 = await import("fs/promises");
|
|
2603
2749
|
const serverOnlyAssets = collectServerOnlySSRAssets(bundle);
|
|
2604
2750
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
2605
2751
|
if (output.type !== "asset" || serverOnlyAssets.has(fileName)) continue;
|
|
@@ -2607,41 +2753,41 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
2607
2753
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
2608
2754
|
continue;
|
|
2609
2755
|
}
|
|
2610
|
-
const filePath =
|
|
2611
|
-
await
|
|
2612
|
-
await
|
|
2756
|
+
const filePath = path15.join(outputDir, fileName);
|
|
2757
|
+
await fs5.mkdir(path15.dirname(filePath), { recursive: true });
|
|
2758
|
+
await fs5.writeFile(filePath, output.source);
|
|
2613
2759
|
}
|
|
2614
2760
|
}
|
|
2615
2761
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
2616
|
-
const
|
|
2762
|
+
const fs5 = await import("fs/promises");
|
|
2617
2763
|
await Promise.all(
|
|
2618
2764
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
2619
|
-
const targetPath =
|
|
2620
|
-
await
|
|
2621
|
-
await
|
|
2765
|
+
const targetPath = path15.join(outputDir, url.replace(/^\/+/, ""));
|
|
2766
|
+
await fs5.mkdir(path15.dirname(targetPath), { recursive: true });
|
|
2767
|
+
await fs5.copyFile(sourcePath, targetPath);
|
|
2622
2768
|
})
|
|
2623
2769
|
);
|
|
2624
2770
|
}
|
|
2625
2771
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
2626
|
-
const
|
|
2627
|
-
const fontCssPath =
|
|
2772
|
+
const fs5 = await import("fs/promises");
|
|
2773
|
+
const fontCssPath = path15.join(outputDir, "farm-fonts.css");
|
|
2628
2774
|
let fontCss = fontCssSource;
|
|
2629
2775
|
if (fontCss === void 0) {
|
|
2630
2776
|
try {
|
|
2631
|
-
fontCss = await
|
|
2777
|
+
fontCss = await fs5.readFile(fontCssPath);
|
|
2632
2778
|
} catch {
|
|
2633
2779
|
return;
|
|
2634
2780
|
}
|
|
2635
2781
|
}
|
|
2636
|
-
const clientCssPath =
|
|
2782
|
+
const clientCssPath = path15.join(outputDir, "farm-client.css");
|
|
2637
2783
|
let clientCss = "";
|
|
2638
2784
|
try {
|
|
2639
|
-
clientCss = await
|
|
2785
|
+
clientCss = await fs5.readFile(clientCssPath, "utf8");
|
|
2640
2786
|
} catch {
|
|
2641
2787
|
}
|
|
2642
2788
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
2643
|
-
await
|
|
2644
|
-
await
|
|
2789
|
+
await fs5.writeFile(fontCssPath, normalizedFontCss);
|
|
2790
|
+
await fs5.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
|
|
2645
2791
|
}
|
|
2646
2792
|
function importsFarmClientBlockedPackage(id, packageName) {
|
|
2647
2793
|
return id === packageName || id.startsWith(`${packageName}/`);
|
|
@@ -2657,28 +2803,28 @@ var IncompleteClientBuildOutputError = class extends Error {
|
|
|
2657
2803
|
}
|
|
2658
2804
|
};
|
|
2659
2805
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
2660
|
-
const
|
|
2806
|
+
const fs5 = await import("fs/promises");
|
|
2661
2807
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
2662
|
-
const clientEntryPath =
|
|
2808
|
+
const clientEntryPath = path15.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
2663
2809
|
let clientEntrySize = 0;
|
|
2664
2810
|
try {
|
|
2665
|
-
const clientEntry = await
|
|
2811
|
+
const clientEntry = await fs5.stat(clientEntryPath);
|
|
2666
2812
|
if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
|
|
2667
2813
|
} catch {
|
|
2668
2814
|
}
|
|
2669
2815
|
if (clientEntrySize === 0) {
|
|
2670
2816
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
2671
2817
|
}
|
|
2672
|
-
const clientCssPath =
|
|
2673
|
-
const globalsCssPath =
|
|
2818
|
+
const clientCssPath = path15.join(outputDir, "farm-client.css");
|
|
2819
|
+
const globalsCssPath = path15.join(root, srcDir, "app", "globals.css");
|
|
2674
2820
|
let expectsCss = false;
|
|
2675
2821
|
try {
|
|
2676
|
-
const globalsCss = await
|
|
2822
|
+
const globalsCss = await fs5.readFile(globalsCssPath, "utf8");
|
|
2677
2823
|
expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
2678
2824
|
} catch {
|
|
2679
2825
|
}
|
|
2680
2826
|
try {
|
|
2681
|
-
const clientCss = await
|
|
2827
|
+
const clientCss = await fs5.stat(clientCssPath);
|
|
2682
2828
|
if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
|
|
2683
2829
|
throw new IncompleteClientBuildOutputError("farm-client.css is empty");
|
|
2684
2830
|
}
|
|
@@ -2687,11 +2833,11 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2687
2833
|
if (expectsCss) {
|
|
2688
2834
|
throw new IncompleteClientBuildOutputError("farm-client.css is missing");
|
|
2689
2835
|
}
|
|
2690
|
-
await
|
|
2836
|
+
await fs5.writeFile(clientCssPath, "");
|
|
2691
2837
|
}
|
|
2692
2838
|
}
|
|
2693
2839
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
2694
|
-
const key =
|
|
2840
|
+
const key = getClientModuleHydrationPlanKey(modulePath, root, mode, options);
|
|
2695
2841
|
let plan = cache.get(key);
|
|
2696
2842
|
if (!plan) {
|
|
2697
2843
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -2699,12 +2845,12 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
2699
2845
|
}
|
|
2700
2846
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
2701
2847
|
}
|
|
2702
|
-
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
|
|
2703
|
-
if (!mobile) await removeFarmMobileClientManifest(
|
|
2848
|
+
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false, sourceSnapshot) {
|
|
2849
|
+
if (!mobile) await removeFarmMobileClientManifest(path15.dirname(outputDir));
|
|
2704
2850
|
const viteBuild = productionVite.build;
|
|
2705
|
-
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2851
|
+
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2706
2852
|
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
2707
|
-
const
|
|
2853
|
+
const fs5 = await import("fs/promises");
|
|
2708
2854
|
const pluginManager = new PluginManager2({
|
|
2709
2855
|
config,
|
|
2710
2856
|
isDev: false,
|
|
@@ -2742,51 +2888,6 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2742
2888
|
...planOptions,
|
|
2743
2889
|
serverTreeLayouts: pagePlanOptions.serverOwners
|
|
2744
2890
|
};
|
|
2745
|
-
const clientLayouts = layoutRoutes.map((layout) => {
|
|
2746
|
-
try {
|
|
2747
|
-
const metadata = getCachedClientModuleHydrationPlan(
|
|
2748
|
-
layout.modulePath,
|
|
2749
|
-
root,
|
|
2750
|
-
isolatedMode,
|
|
2751
|
-
hydrationPlanCache,
|
|
2752
|
-
layoutPlanOptions
|
|
2753
|
-
);
|
|
2754
|
-
return {
|
|
2755
|
-
...layout,
|
|
2756
|
-
shouldHydrate: metadata.shouldHydrate,
|
|
2757
|
-
islandStrategy: metadata.islandStrategy,
|
|
2758
|
-
legacyShouldHydrate: metadata.legacyShouldHydrate,
|
|
2759
|
-
legacyIslandStrategy: metadata.legacyIslandStrategy,
|
|
2760
|
-
mode: metadata.mode,
|
|
2761
|
-
estimatedIsolatedRootCount: metadata.estimatedIsolatedRootCount,
|
|
2762
|
-
hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries,
|
|
2763
|
-
isolatedHydrationEligible: metadata.isolatedHydrationEligible,
|
|
2764
|
-
isolatedBoundaries: metadata.isolatedBoundaries,
|
|
2765
|
-
asyncOwnerIslands: metadata.asyncOwnerIslands,
|
|
2766
|
-
suppressedAsyncHydration: metadata.suppressedAsyncHydration,
|
|
2767
|
-
fallbackReason: metadata.fallbackReason,
|
|
2768
|
-
serverTreeLayout: metadata.serverTreeLayout
|
|
2769
|
-
};
|
|
2770
|
-
} catch (error) {
|
|
2771
|
-
logger.warn(`\u26A0\uFE0F Could not inspect layout file ${layout.modulePath}: ${error}`);
|
|
2772
|
-
return {
|
|
2773
|
-
...layout,
|
|
2774
|
-
shouldHydrate: false,
|
|
2775
|
-
islandStrategy: null,
|
|
2776
|
-
legacyShouldHydrate: false,
|
|
2777
|
-
legacyIslandStrategy: null,
|
|
2778
|
-
mode: isolatedMode,
|
|
2779
|
-
estimatedIsolatedRootCount: 0,
|
|
2780
|
-
hasIsolatedClientBoundaries: false,
|
|
2781
|
-
isolatedHydrationEligible: false,
|
|
2782
|
-
isolatedBoundaries: [],
|
|
2783
|
-
asyncOwnerIslands: void 0,
|
|
2784
|
-
suppressedAsyncHydration: void 0,
|
|
2785
|
-
fallbackReason: void 0,
|
|
2786
|
-
serverTreeLayout: void 0
|
|
2787
|
-
};
|
|
2788
|
-
}
|
|
2789
|
-
});
|
|
2790
2891
|
const layoutAppliesToRoute = routeBoundaryCoversDirectory;
|
|
2791
2892
|
const routeDirectory = (route) => route.directory ?? route.pattern;
|
|
2792
2893
|
const islandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
|
|
@@ -2802,168 +2903,221 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2802
2903
|
);
|
|
2803
2904
|
const syntheticDocsEntry = config.docs?.enabled && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
|
|
2804
2905
|
const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
|
|
2805
|
-
const
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
})
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
metadata: {
|
|
2837
|
-
mode: isolatedMode,
|
|
2906
|
+
const plan = (operation) => sourceSnapshot ? withFarmSourceSnapshotOf(sourceSnapshot, operation) : withFarmSourceSnapshot(operation);
|
|
2907
|
+
const { clientLayouts, clientRouteSlots } = plan(() => {
|
|
2908
|
+
const clientLayouts2 = layoutRoutes.map((layout) => {
|
|
2909
|
+
try {
|
|
2910
|
+
const metadata = getCachedClientModuleHydrationPlan(
|
|
2911
|
+
layout.modulePath,
|
|
2912
|
+
root,
|
|
2913
|
+
isolatedMode,
|
|
2914
|
+
hydrationPlanCache,
|
|
2915
|
+
layoutPlanOptions
|
|
2916
|
+
);
|
|
2917
|
+
return {
|
|
2918
|
+
...layout,
|
|
2919
|
+
shouldHydrate: metadata.shouldHydrate,
|
|
2920
|
+
islandStrategy: metadata.islandStrategy,
|
|
2921
|
+
legacyShouldHydrate: metadata.legacyShouldHydrate,
|
|
2922
|
+
legacyIslandStrategy: metadata.legacyIslandStrategy,
|
|
2923
|
+
mode: metadata.mode,
|
|
2924
|
+
estimatedIsolatedRootCount: metadata.estimatedIsolatedRootCount,
|
|
2925
|
+
hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries,
|
|
2926
|
+
isolatedHydrationEligible: metadata.isolatedHydrationEligible,
|
|
2927
|
+
isolatedBoundaries: metadata.isolatedBoundaries,
|
|
2928
|
+
asyncOwnerIslands: metadata.asyncOwnerIslands,
|
|
2929
|
+
suppressedAsyncHydration: metadata.suppressedAsyncHydration,
|
|
2930
|
+
fallbackReason: metadata.fallbackReason,
|
|
2931
|
+
serverTreeLayout: metadata.serverTreeLayout
|
|
2932
|
+
};
|
|
2933
|
+
} catch (error) {
|
|
2934
|
+
logger.warn(`\u26A0\uFE0F Could not inspect layout file ${layout.modulePath}: ${error}`);
|
|
2935
|
+
return {
|
|
2936
|
+
...layout,
|
|
2838
2937
|
shouldHydrate: false,
|
|
2839
2938
|
islandStrategy: null,
|
|
2840
2939
|
legacyShouldHydrate: false,
|
|
2841
2940
|
legacyIslandStrategy: null,
|
|
2941
|
+
mode: isolatedMode,
|
|
2842
2942
|
estimatedIsolatedRootCount: 0,
|
|
2843
2943
|
hasIsolatedClientBoundaries: false,
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
for (const layout of clientLayouts) {
|
|
2852
|
-
const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, routeDirectory(route))) || docsEntries.some((docsEntry) => layoutAppliesToRoute(layout.pattern, docsEntry));
|
|
2853
|
-
if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
|
|
2854
|
-
logger.warn(`\u26A0\uFE0F ${describeSuppressedAsyncHydration(layout.pattern, layout.fallbackReason)}`);
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
if (isolatedMode === "analyze") {
|
|
2858
|
-
for (const { entry, metadata } of [
|
|
2859
|
-
...clientLayouts.map((layout) => ({ entry: layout, metadata: layout })),
|
|
2860
|
-
...routePlans.map(({ route, metadata: metadata2 }) => ({ entry: route, metadata: metadata2 }))
|
|
2861
|
-
]) {
|
|
2862
|
-
if (!("isolatedHydrationEligible" in metadata) || !metadata.isolatedHydrationEligible) {
|
|
2863
|
-
continue;
|
|
2944
|
+
isolatedHydrationEligible: false,
|
|
2945
|
+
isolatedBoundaries: [],
|
|
2946
|
+
asyncOwnerIslands: void 0,
|
|
2947
|
+
suppressedAsyncHydration: void 0,
|
|
2948
|
+
fallbackReason: void 0,
|
|
2949
|
+
serverTreeLayout: void 0
|
|
2950
|
+
};
|
|
2864
2951
|
}
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
)
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
|
|
2871
|
-
const plan = getCachedClientModuleHydrationPlan(
|
|
2872
|
-
slot.modulePath,
|
|
2952
|
+
});
|
|
2953
|
+
const markdownPagePlan = createMarkdownPageHydrationPlanner(
|
|
2954
|
+
resolveFarmMdxComponentsModulePath(resolveMdxConfig(config.mdx), root),
|
|
2873
2955
|
root,
|
|
2874
2956
|
isolatedMode,
|
|
2875
|
-
|
|
2876
|
-
{ ...pagePlanOptions, serverOwners: true }
|
|
2957
|
+
{ ...planOptions, packageReferences: pagePlanOptions.serverOwners }
|
|
2877
2958
|
);
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2959
|
+
const routePlans = pageRoutes.map((route) => ({
|
|
2960
|
+
route,
|
|
2961
|
+
metadata: isFarmMarkdownPageFile(route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
|
|
2962
|
+
route.modulePath,
|
|
2963
|
+
root,
|
|
2964
|
+
isolatedMode,
|
|
2965
|
+
hydrationPlanCache,
|
|
2966
|
+
pagePlanOptions
|
|
2967
|
+
)
|
|
2968
|
+
}));
|
|
2969
|
+
enforceFarmIsolatedHydrationRouteBudget(
|
|
2970
|
+
clientLayouts2.map((layout) => ({
|
|
2971
|
+
pattern: layout.pattern,
|
|
2972
|
+
depth: layout.pattern.split("/").filter(Boolean).length,
|
|
2973
|
+
metadata: layout
|
|
2974
|
+
})),
|
|
2975
|
+
[
|
|
2976
|
+
...routePlans.map(({ route, metadata }) => ({
|
|
2977
|
+
pattern: routeDirectory(route),
|
|
2978
|
+
depth: getRouteDirectoryDepth(routeDirectory(route)),
|
|
2979
|
+
metadata
|
|
2980
|
+
})),
|
|
2981
|
+
...syntheticDocsPatterns.map((pattern) => ({
|
|
2982
|
+
pattern,
|
|
2983
|
+
depth: pattern.split("/").filter(Boolean).length,
|
|
2984
|
+
metadata: {
|
|
2985
|
+
mode: isolatedMode,
|
|
2986
|
+
shouldHydrate: false,
|
|
2987
|
+
islandStrategy: null,
|
|
2988
|
+
legacyShouldHydrate: false,
|
|
2989
|
+
legacyIslandStrategy: null,
|
|
2990
|
+
estimatedIsolatedRootCount: 0,
|
|
2991
|
+
hasIsolatedClientBoundaries: false,
|
|
2992
|
+
isolatedBoundaries: []
|
|
2993
|
+
}
|
|
2994
|
+
}))
|
|
2995
|
+
],
|
|
2996
|
+
layoutAppliesToRoute,
|
|
2997
|
+
{ serverOwners: islandsMode }
|
|
2998
|
+
);
|
|
2999
|
+
for (const layout of clientLayouts2) {
|
|
3000
|
+
const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, routeDirectory(route))) || docsEntries.some((docsEntry) => layoutAppliesToRoute(layout.pattern, docsEntry));
|
|
3001
|
+
if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
|
|
2887
3002
|
logger.warn(
|
|
2888
|
-
`\u26A0\uFE0F ${describeSuppressedAsyncHydration(
|
|
3003
|
+
`\u26A0\uFE0F ${describeSuppressedAsyncHydration(layout.pattern, layout.fallbackReason)}`
|
|
2889
3004
|
);
|
|
2890
3005
|
}
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
3006
|
+
}
|
|
3007
|
+
if (isolatedMode === "analyze") {
|
|
3008
|
+
for (const { entry, metadata } of [
|
|
3009
|
+
...clientLayouts2.map((layout) => ({ entry: layout, metadata: layout })),
|
|
3010
|
+
...routePlans.map(({ route, metadata: metadata2 }) => ({ entry: route, metadata: metadata2 }))
|
|
3011
|
+
]) {
|
|
3012
|
+
if (!("isolatedHydrationEligible" in metadata) || !metadata.isolatedHydrationEligible) {
|
|
3013
|
+
continue;
|
|
3014
|
+
}
|
|
3015
|
+
logger.info(
|
|
3016
|
+
`\u{1F4CA} Isolated hydration analysis: ${entry.modulePath} can exclude its server owner and hydrate ${metadata.isolatedBoundaries.length} client ${metadata.isolatedBoundaries.length === 1 ? "boundary" : "boundaries"}.`
|
|
2902
3017
|
);
|
|
2903
|
-
clientPages.push({
|
|
2904
|
-
...route,
|
|
2905
|
-
relativePath,
|
|
2906
|
-
pageShouldHydrate: metadata.shouldHydrate,
|
|
2907
|
-
islandStrategy,
|
|
2908
|
-
hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries || applicableClientLayouts.some((layout) => layout.hasIsolatedClientBoundaries) || slotBoundaries.length > 0,
|
|
2909
|
-
isolatedBoundaries: [
|
|
2910
|
-
...metadata.hasIsolatedClientBoundaries ? metadata.isolatedBoundaries : [],
|
|
2911
|
-
...slotBoundaries,
|
|
2912
|
-
...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
|
|
2913
|
-
],
|
|
2914
|
-
// The server renders a server tree only below a hydrating layout.
|
|
2915
|
-
...usesFarmServerTree(metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
|
|
2916
|
-
});
|
|
2917
|
-
logger.info(`\u{1F4F1} Found hydratable route: ${route.pattern} -> ${route.modulePath}`);
|
|
2918
3018
|
}
|
|
2919
|
-
} catch (error) {
|
|
2920
|
-
logger.warn(`\u26A0\uFE0F Could not inspect route file ${route.modulePath}: ${error}`);
|
|
2921
3019
|
}
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
const hydrationStrategies = applicableClientLayouts.flatMap(
|
|
2930
|
-
(layout) => layout.islandStrategy ? [layout.islandStrategy] : []
|
|
3020
|
+
const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
|
|
3021
|
+
const plan2 = getCachedClientModuleHydrationPlan(
|
|
3022
|
+
slot.modulePath,
|
|
3023
|
+
root,
|
|
3024
|
+
isolatedMode,
|
|
3025
|
+
hydrationPlanCache,
|
|
3026
|
+
{ ...pagePlanOptions, serverOwners: true }
|
|
2931
3027
|
);
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3028
|
+
return plan2.isClientComponent ? [] : [{ slot, plan: plan2 }];
|
|
3029
|
+
}) : [];
|
|
3030
|
+
for (const { route, metadata } of routePlans) {
|
|
3031
|
+
if (isAdapterDocsRoute(route.pattern)) continue;
|
|
3032
|
+
try {
|
|
3033
|
+
const applicableClientLayouts = clientLayouts2.filter(
|
|
3034
|
+
(layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, routeDirectory(route))
|
|
3035
|
+
);
|
|
3036
|
+
if (metadata.suppressedAsyncHydration) {
|
|
3037
|
+
logger.warn(
|
|
3038
|
+
`\u26A0\uFE0F ${describeSuppressedAsyncHydration(route.pattern, metadata.fallbackReason)}`
|
|
3039
|
+
);
|
|
3040
|
+
}
|
|
3041
|
+
const slotBoundaries = serverSlotPlans.filter(
|
|
3042
|
+
({ slot }) => layoutAppliesToRoute(slot.ownerDirectory ?? slot.ownerPattern, routeDirectory(route))
|
|
3043
|
+
).flatMap(({ plan: plan2 }) => plan2.isolatedBoundaries);
|
|
3044
|
+
if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0 || slotBoundaries.length > 0) {
|
|
3045
|
+
const relativePath = route.modulePath.replace(root, "").replace(/^\//, "");
|
|
3046
|
+
const islandStrategy = resolveFarmRouteRootStrategy(
|
|
3047
|
+
route,
|
|
3048
|
+
metadata,
|
|
3049
|
+
clientLayouts2,
|
|
3050
|
+
root,
|
|
3051
|
+
islandsMode
|
|
3052
|
+
);
|
|
3053
|
+
clientPages.push({
|
|
3054
|
+
...route,
|
|
3055
|
+
relativePath,
|
|
3056
|
+
pageShouldHydrate: metadata.shouldHydrate,
|
|
3057
|
+
islandStrategy,
|
|
3058
|
+
hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries || applicableClientLayouts.some((layout) => layout.hasIsolatedClientBoundaries) || slotBoundaries.length > 0,
|
|
3059
|
+
isolatedBoundaries: [
|
|
3060
|
+
...metadata.hasIsolatedClientBoundaries ? metadata.isolatedBoundaries : [],
|
|
3061
|
+
...slotBoundaries,
|
|
3062
|
+
...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
|
|
3063
|
+
],
|
|
3064
|
+
// The server renders a server tree only below a hydrating layout.
|
|
3065
|
+
...usesFarmServerTree(metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
|
|
3066
|
+
});
|
|
3067
|
+
logger.info(`\u{1F4F1} Found hydratable route: ${route.pattern} -> ${route.modulePath}`);
|
|
3068
|
+
}
|
|
3069
|
+
} catch (error) {
|
|
3070
|
+
logger.warn(`\u26A0\uFE0F Could not inspect route file ${route.modulePath}: ${error}`);
|
|
3071
|
+
}
|
|
2948
3072
|
}
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
3073
|
+
if (syntheticDocsEntry) {
|
|
3074
|
+
const docsEntry = syntheticDocsEntry;
|
|
3075
|
+
const applicableClientLayouts = clientLayouts2.filter(
|
|
3076
|
+
(layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, docsEntry)
|
|
3077
|
+
);
|
|
3078
|
+
if (applicableClientLayouts.length > 0) {
|
|
3079
|
+
const hydrationStrategies = applicableClientLayouts.flatMap(
|
|
3080
|
+
(layout) => layout.islandStrategy ? [layout.islandStrategy] : []
|
|
3081
|
+
);
|
|
3082
|
+
const islandStrategy = hydrationStrategies.every(
|
|
3083
|
+
(strategy) => strategy === hydrationStrategies[0]
|
|
3084
|
+
) ? hydrationStrategies[0] ?? "load" : "load";
|
|
3085
|
+
const docsClientRoutes = syntheticDocsPatterns.map((pattern) => ({
|
|
3086
|
+
pattern,
|
|
3087
|
+
docs: true,
|
|
3088
|
+
modulePath: "",
|
|
3089
|
+
relativePath: "",
|
|
3090
|
+
pageShouldHydrate: false,
|
|
3091
|
+
islandStrategy,
|
|
3092
|
+
hasIsolatedClientBoundaries: applicableClientLayouts.some(
|
|
3093
|
+
(layout) => layout.hasIsolatedClientBoundaries
|
|
3094
|
+
),
|
|
3095
|
+
isolatedBoundaries: applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
|
|
3096
|
+
}));
|
|
3097
|
+
clientPages.unshift(...docsClientRoutes);
|
|
3098
|
+
}
|
|
2957
3099
|
}
|
|
3100
|
+
const clientRouteSlots2 = routeSlots.filter((slot) => {
|
|
3101
|
+
try {
|
|
3102
|
+
const metadata = getClientModuleMetadata(slot.modulePath, root);
|
|
3103
|
+
return metadata.shouldHydrate && (!islandsMode || metadata.isClientComponent);
|
|
3104
|
+
} catch (error) {
|
|
3105
|
+
logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
|
|
3106
|
+
return false;
|
|
3107
|
+
}
|
|
3108
|
+
});
|
|
3109
|
+
return { clientLayouts: clientLayouts2, clientRouteSlots: clientRouteSlots2 };
|
|
2958
3110
|
});
|
|
2959
3111
|
logger.info(
|
|
2960
3112
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2961
3113
|
);
|
|
3114
|
+
const clientRouteTable = createFarmClientRouteTable(clientPages);
|
|
3115
|
+
await writeFarmClientRouteTable(path15.dirname(outputDir), clientRouteTable);
|
|
2962
3116
|
const buildTarget = async (platform) => {
|
|
2963
|
-
const clientEntryRoot =
|
|
2964
|
-
await
|
|
2965
|
-
const clientEntryDir = await
|
|
2966
|
-
const clientEntryPath =
|
|
3117
|
+
const clientEntryRoot = path15.join(root, ".farm", "tmp");
|
|
3118
|
+
await fs5.mkdir(clientEntryRoot, { recursive: true });
|
|
3119
|
+
const clientEntryDir = await fs5.mkdtemp(path15.join(clientEntryRoot, "client-entry-"));
|
|
3120
|
+
const clientEntryPath = path15.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2967
3121
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2968
3122
|
clientPages,
|
|
2969
3123
|
clientLayouts,
|
|
@@ -2995,14 +3149,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2995
3149
|
);
|
|
2996
3150
|
const entryName = platform === "mobile" ? FARM_MOBILE_CLIENT_ENTRY_NAME : "farm-client";
|
|
2997
3151
|
const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
|
|
2998
|
-
await
|
|
3152
|
+
await fs5.writeFile(clientEntryPath, clientEntry.entry);
|
|
3153
|
+
await fs5.writeFile(
|
|
3154
|
+
path15.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`),
|
|
3155
|
+
generateFarmClientRouteTableModule(clientRouteTable)
|
|
3156
|
+
);
|
|
2999
3157
|
if (clientEntry.router !== void 0) {
|
|
3000
|
-
await
|
|
3158
|
+
await fs5.writeFile(path15.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
|
|
3001
3159
|
}
|
|
3002
3160
|
const clientInput = { [entryName]: clientEntryPath };
|
|
3003
3161
|
if (platform === "web" && canBootFarmIslandsClient(config)) {
|
|
3004
|
-
const clientBootPath =
|
|
3005
|
-
await
|
|
3162
|
+
const clientBootPath = path15.join(clientEntryDir, "farm-client-boot.tsx");
|
|
3163
|
+
await fs5.writeFile(
|
|
3006
3164
|
clientBootPath,
|
|
3007
3165
|
'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
|
|
3008
3166
|
);
|
|
@@ -3018,8 +3176,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3018
3176
|
if (hasScopedPostcssConfig) {
|
|
3019
3177
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
3020
3178
|
} else {
|
|
3021
|
-
const postcssConfigPath =
|
|
3022
|
-
await
|
|
3179
|
+
const postcssConfigPath = path15.join(clientEntryDir, "postcss.config.cjs");
|
|
3180
|
+
await fs5.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
3023
3181
|
postcssSearchPath = clientEntryDir;
|
|
3024
3182
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
3025
3183
|
builder: productionVite.builder,
|
|
@@ -3074,24 +3232,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3074
3232
|
plugins: [
|
|
3075
3233
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
3076
3234
|
createFarmPrivateClientSourcemapsPlugin({
|
|
3077
|
-
outDir:
|
|
3078
|
-
|
|
3235
|
+
outDir: path15.join(
|
|
3236
|
+
path15.dirname(outputDir),
|
|
3079
3237
|
platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
|
|
3080
3238
|
)
|
|
3081
3239
|
}),
|
|
3082
3240
|
// The web client's preload manifests; the mobile client records its files instead.
|
|
3083
3241
|
platform === "mobile" ? createFarmMobileClientManifestPlugin({
|
|
3084
|
-
buildDir:
|
|
3242
|
+
buildDir: path15.dirname(outputDir),
|
|
3085
3243
|
entryName
|
|
3086
3244
|
}) : createFarmClientModulePreloadPlugin({
|
|
3087
3245
|
root,
|
|
3088
|
-
buildDir:
|
|
3246
|
+
buildDir: path15.dirname(outputDir),
|
|
3089
3247
|
entryName: "farm-client"
|
|
3090
3248
|
}),
|
|
3091
3249
|
...adapterOwnsDocsRuntime && platform === "web" ? [
|
|
3092
3250
|
createFarmDocsModulePreloadPlugin({
|
|
3093
3251
|
root,
|
|
3094
|
-
buildDir:
|
|
3252
|
+
buildDir: path15.dirname(outputDir),
|
|
3095
3253
|
importer: clientEntryPath,
|
|
3096
3254
|
entryName: "farm-client",
|
|
3097
3255
|
modules: [
|
|
@@ -3170,8 +3328,9 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3170
3328
|
}
|
|
3171
3329
|
}
|
|
3172
3330
|
},
|
|
3331
|
+
farmIslandContainersPlugin(config),
|
|
3173
3332
|
farmPlugin(
|
|
3174
|
-
{ ...config, isolatedClientBoundaryModules, programmaticClientRoutes },
|
|
3333
|
+
{ ...config, isolatedClientBoundaryModules, programmaticClientRoutes, sourceSnapshot },
|
|
3175
3334
|
pluginManager
|
|
3176
3335
|
),
|
|
3177
3336
|
farmEnvironmentFunctionsPlugin(config)
|
|
@@ -3199,8 +3358,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3199
3358
|
mergeFarmProductionViteConfig(clientViteConfig, config.vite, { clientOutput: true })
|
|
3200
3359
|
);
|
|
3201
3360
|
if (platform === "mobile") {
|
|
3202
|
-
await
|
|
3203
|
-
if (!await hasFarmMobileClientEntry(
|
|
3361
|
+
await fs5.rm(path15.join(outputDir, `${entryName}.css`), { force: true });
|
|
3362
|
+
if (!await hasFarmMobileClientEntry(path15.dirname(outputDir), outputDir)) {
|
|
3204
3363
|
throw new IncompleteClientBuildOutputError(
|
|
3205
3364
|
`${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
|
|
3206
3365
|
);
|
|
@@ -3211,7 +3370,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3211
3370
|
}
|
|
3212
3371
|
} finally {
|
|
3213
3372
|
try {
|
|
3214
|
-
await
|
|
3373
|
+
await fs5.rm(clientEntryDir, { recursive: true, force: true });
|
|
3215
3374
|
} catch {
|
|
3216
3375
|
}
|
|
3217
3376
|
}
|
|
@@ -3221,17 +3380,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3221
3380
|
}
|
|
3222
3381
|
function toBakedMarkdownSourcePath(root, filePath) {
|
|
3223
3382
|
if (!filePath) return "";
|
|
3224
|
-
if (!
|
|
3225
|
-
const relative =
|
|
3226
|
-
if (!relative || relative.startsWith("..") ||
|
|
3227
|
-
return
|
|
3383
|
+
if (!path15.isAbsolute(filePath)) return filePath.split(path15.sep).join("/");
|
|
3384
|
+
const relative = path15.relative(root, filePath);
|
|
3385
|
+
if (!relative || relative.startsWith("..") || path15.isAbsolute(relative)) {
|
|
3386
|
+
return path15.basename(filePath);
|
|
3228
3387
|
}
|
|
3229
|
-
return relative.split(
|
|
3388
|
+
return relative.split(path15.sep).join("/");
|
|
3230
3389
|
}
|
|
3231
3390
|
function generateUniversalRouterStateRuntime(streamNavigations = false) {
|
|
3232
3391
|
return `
|
|
3233
3392
|
const FARM_PAGE_STATE_KEY = "__farmPageState";
|
|
3234
3393
|
const FARM_HISTORY_INDEX_KEY = "__farmHistoryIndex";
|
|
3394
|
+
const FARM_HISTORY_KEY = "__farmHistoryKey";
|
|
3235
3395
|
const IDLE_NAVIGATION_STATE = {
|
|
3236
3396
|
state: "idle",
|
|
3237
3397
|
pending: false,
|
|
@@ -3251,8 +3411,8 @@ function createNavigationLocation(url) {
|
|
|
3251
3411
|
};
|
|
3252
3412
|
}
|
|
3253
3413
|
|
|
3254
|
-
function scrollElementStorageKey(
|
|
3255
|
-
return "farm-scroll-" +
|
|
3414
|
+
function scrollElementStorageKey(scrollKey, key) {
|
|
3415
|
+
return "farm-scroll-" + scrollKey + ":" + key;
|
|
3256
3416
|
}
|
|
3257
3417
|
|
|
3258
3418
|
function createHistoryState(path, pageState, currentState) {
|
|
@@ -3311,12 +3471,140 @@ function readHistoryIndex(state) {
|
|
|
3311
3471
|
return Number.isSafeInteger(value) ? value : null;
|
|
3312
3472
|
}
|
|
3313
3473
|
|
|
3474
|
+
function readHistoryKey(state) {
|
|
3475
|
+
if (!state || typeof state !== "object") return null;
|
|
3476
|
+
const value = state[FARM_HISTORY_KEY];
|
|
3477
|
+
return typeof value === "string" && value.length > 0 && value.length <= 64 ? value : null;
|
|
3478
|
+
}
|
|
3479
|
+
|
|
3480
|
+
// The time keeps keys unique across the reloads and documents that share a tab's sessionStorage.
|
|
3481
|
+
function createHistoryKey() {
|
|
3482
|
+
return Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 10);
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
// Scroll positions are saved per history entry, so the same URL twice in history keeps two
|
|
3486
|
+
// positions. An entry Farm did not write has no key and falls back to its path.
|
|
3487
|
+
function historyScrollKey(state, path) {
|
|
3488
|
+
return readHistoryKey(state) || path;
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3314
3491
|
/*farm-router-end*/
|
|
3315
3492
|
function hasAbsoluteNavigationHref(href) {
|
|
3316
3493
|
return /^[a-zA-Z][a-zA-Z\\d+.-]*:/.test(href) || href.startsWith("//");
|
|
3317
3494
|
}
|
|
3318
3495
|
`.trim();
|
|
3319
3496
|
}
|
|
3497
|
+
function generateFarmClientRouteTableRuntime(options) {
|
|
3498
|
+
const prefetch = `const farmPrefetchWhileRouteTableLoads = ${!options.streamNavigations};`;
|
|
3499
|
+
if (!options.table) {
|
|
3500
|
+
return `${prefetch}
|
|
3501
|
+
const clientRoutes = [];
|
|
3502
|
+
const clientRouteMatcher = createFarmRouter([]);
|
|
3503
|
+
const clientPageRouteMatcher = clientRouteMatcher;
|
|
3504
|
+
function loadFarmClientRouteTable() { return null; }
|
|
3505
|
+
function prefetchFarmClientRouteTable() {}
|
|
3506
|
+
const farmClientRoutesBoot = null;`;
|
|
3507
|
+
}
|
|
3508
|
+
return `${prefetch}
|
|
3509
|
+
let clientRoutes = [];
|
|
3510
|
+
let clientRouteMatcher = createFarmRouter([]);
|
|
3511
|
+
let clientPageRouteMatcher = clientRouteMatcher;
|
|
3512
|
+
let farmClientRouteTableLoad = null;
|
|
3513
|
+
let farmClientRouteTableLoaded = false;
|
|
3514
|
+
|
|
3515
|
+
function setFarmClientRoutes(routes) {
|
|
3516
|
+
clientRoutes = routes.map(function(route) {
|
|
3517
|
+
const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
|
|
3518
|
+
return { ...route, navigation: "html-fragment", load: load || null };
|
|
3519
|
+
});
|
|
3520
|
+
clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
|
|
3521
|
+
return { path: route.pattern, meta: route };
|
|
3522
|
+
}));
|
|
3523
|
+
clientPageRouteMatcher = ${options.docs ? `createFarmRouter(clientRoutes.filter(function(route) {
|
|
3524
|
+
return !route.docs;
|
|
3525
|
+
}).map(function(route) {
|
|
3526
|
+
return { path: route.pattern, meta: route };
|
|
3527
|
+
}))` : "clientRouteMatcher"};
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
// Null once the whole table is in place, else a promise that settles when it is.
|
|
3531
|
+
function loadFarmClientRouteTable() {
|
|
3532
|
+
if (farmClientRouteTableLoaded) return null;
|
|
3533
|
+
return farmClientRouteTableLoad || (farmClientRouteTableLoad = import("./${FARM_CLIENT_ROUTE_TABLE_MODULE}").then(function(module) {
|
|
3534
|
+
setFarmClientRoutes(module.default);
|
|
3535
|
+
farmClientRouteTableLoaded = true;
|
|
3536
|
+
}, function(error) {
|
|
3537
|
+
farmClientRouteTableLoad = null;
|
|
3538
|
+
throw error;
|
|
3539
|
+
}));
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
// A navigation to come (a prefetch, the lazy router) warms the table; that navigation handles a failure.
|
|
3543
|
+
function prefetchFarmClientRouteTable() {
|
|
3544
|
+
const table = loadFarmClientRouteTable();
|
|
3545
|
+
if (table) table.catch(function() {});
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
const farmClientRoutesBoot = (function() {
|
|
3549
|
+
const boot = window.__FARM_CLIENT_ROUTES__;
|
|
3550
|
+
if (boot && Array.isArray(boot.routes) && boot.path === getFarmRoutePathname(window.location.pathname)) {
|
|
3551
|
+
setFarmClientRoutes(boot.routes);
|
|
3552
|
+
return null;
|
|
3553
|
+
}
|
|
3554
|
+
return loadFarmClientRouteTable().catch(function(error) {
|
|
3555
|
+
console.warn("[Farm.js] Could not load the client route table; the page was left as the server rendered it.", error);
|
|
3556
|
+
});
|
|
3557
|
+
})();
|
|
3558
|
+
|
|
3559
|
+
// A plain <a> has no prefetch, unlike Link: a pointer or focus reaching one warms the table its
|
|
3560
|
+
// navigation will read.
|
|
3561
|
+
const FARM_ROUTE_TABLE_INTENT_EVENTS = ["pointerover", "pointerdown", "focusin", "touchstart"];
|
|
3562
|
+
function warmFarmClientRouteTable(event) {
|
|
3563
|
+
const target = event.target;
|
|
3564
|
+
if (!target || !target.closest || !target.closest("a[href]")) return;
|
|
3565
|
+
for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
|
|
3566
|
+
document.removeEventListener(type, warmFarmClientRouteTable, true);
|
|
3567
|
+
}
|
|
3568
|
+
prefetchFarmClientRouteTable();
|
|
3569
|
+
}
|
|
3570
|
+
for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
|
|
3571
|
+
document.addEventListener(type, warmFarmClientRouteTable, { capture: true, passive: true });
|
|
3572
|
+
}`;
|
|
3573
|
+
}
|
|
3574
|
+
function generateFarmClientBootRoutesServerSource(tableSource) {
|
|
3575
|
+
return `// The client route table (client-route-table.ts), filled in from the client build. The client
|
|
3576
|
+
// loads it on its first navigation; a document names the entries its page boots with, found
|
|
3577
|
+
// with the client's own matcher, so its page hydrates without the table.
|
|
3578
|
+
const farmClientRouteTable = (() => {
|
|
3579
|
+
try {
|
|
3580
|
+
const table = JSON.parse(${tableSource});
|
|
3581
|
+
if (!Array.isArray(table) || table.length === 0) return null;
|
|
3582
|
+
const toRoute = function(route) { return { path: route.pattern, meta: route }; };
|
|
3583
|
+
const routes = createFarmRouter(table.map(toRoute));
|
|
3584
|
+
return {
|
|
3585
|
+
routes: routes,
|
|
3586
|
+
pages: table.some(function(route) { return route.docs; })
|
|
3587
|
+
? createFarmRouter(table.filter(function(route) { return !route.docs; }).map(toRoute))
|
|
3588
|
+
: routes,
|
|
3589
|
+
};
|
|
3590
|
+
} catch {
|
|
3591
|
+
return null;
|
|
3592
|
+
}
|
|
3593
|
+
})();
|
|
3594
|
+
|
|
3595
|
+
// The entries the client's matchRoute and getFarmPageDirectory read for this route path.
|
|
3596
|
+
function getFarmClientBootRoutes(routePathname) {
|
|
3597
|
+
if (!farmClientRouteTable || typeof routePathname !== "string") return undefined;
|
|
3598
|
+
const routes = [];
|
|
3599
|
+
const matched = farmClientRouteTable.routes.match(routePathname);
|
|
3600
|
+
if (matched) {
|
|
3601
|
+
routes.push(matched.route.meta);
|
|
3602
|
+
const page = matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
|
|
3603
|
+
if (page) routes.push(page.route.meta);
|
|
3604
|
+
}
|
|
3605
|
+
return { path: routePathname, routes: routes };
|
|
3606
|
+
}`;
|
|
3607
|
+
}
|
|
3320
3608
|
function generateClientPageDirectorySource() {
|
|
3321
3609
|
return `function getFarmPageDirectory(pathname) {
|
|
3322
3610
|
const path = getFarmRoutePathname(pathname);
|
|
@@ -3643,7 +3931,8 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3643
3931
|
|
|
3644
3932
|
initializeHistory: function() {
|
|
3645
3933
|
const existingIndex = readHistoryIndex(window.history.state);
|
|
3646
|
-
|
|
3934
|
+
const existingKey = readHistoryKey(window.history.state);
|
|
3935
|
+
if (existingIndex != null && existingKey != null) {
|
|
3647
3936
|
this.currentHistoryIndex = existingIndex;
|
|
3648
3937
|
this.currentHistoryState = window.history.state;
|
|
3649
3938
|
return;
|
|
@@ -3653,14 +3942,15 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3653
3942
|
...(window.history.state && typeof window.history.state === "object"
|
|
3654
3943
|
? window.history.state
|
|
3655
3944
|
: {}),
|
|
3656
|
-
[FARM_HISTORY_INDEX_KEY]: 0,
|
|
3945
|
+
[FARM_HISTORY_INDEX_KEY]: existingIndex != null ? existingIndex : 0,
|
|
3946
|
+
[FARM_HISTORY_KEY]: existingKey || createHistoryKey(),
|
|
3657
3947
|
};
|
|
3658
3948
|
window.history.replaceState(initialState, "", window.location.href);
|
|
3659
|
-
this.currentHistoryIndex =
|
|
3949
|
+
this.currentHistoryIndex = initialState[FARM_HISTORY_INDEX_KEY];
|
|
3660
3950
|
this.currentHistoryState = initialState;
|
|
3661
3951
|
} catch {
|
|
3662
|
-
this.currentHistoryIndex =
|
|
3663
|
-
this.currentHistoryState = null;
|
|
3952
|
+
this.currentHistoryIndex = existingIndex;
|
|
3953
|
+
this.currentHistoryState = existingIndex != null ? window.history.state : null;
|
|
3664
3954
|
}
|
|
3665
3955
|
},
|
|
3666
3956
|
|
|
@@ -3953,6 +4243,9 @@ ${streamNavigations ? ` if (streamShell && response.body) {
|
|
|
3953
4243
|
? this.currentHistoryIndex
|
|
3954
4244
|
: this.currentHistoryIndex + 1;
|
|
3955
4245
|
if (nextIndex != null) nextState[FARM_HISTORY_INDEX_KEY] = nextIndex;
|
|
4246
|
+
// A push is a new entry; createHistoryState copied the current entry's key into it.
|
|
4247
|
+
nextState[FARM_HISTORY_KEY] =
|
|
4248
|
+
(action === "replace" && readHistoryKey(nextState)) || createHistoryKey();
|
|
3956
4249
|
if (action === "replace") window.history.replaceState(nextState, "", url);
|
|
3957
4250
|
else window.history.pushState(nextState, "", url);
|
|
3958
4251
|
this.currentHistoryIndex = nextIndex;
|
|
@@ -3968,43 +4261,54 @@ ${streamNavigations ? ` if (streamShell && response.body) {
|
|
|
3968
4261
|
|
|
3969
4262
|
registerScrollElement: function(key, element) {
|
|
3970
4263
|
this.scrollElements.set(key, element);
|
|
3971
|
-
this.restoreScrollElement(
|
|
4264
|
+
this.restoreScrollElement(
|
|
4265
|
+
historyScrollKey(this.currentHistoryState, window.location.pathname + window.location.search),
|
|
4266
|
+
key,
|
|
4267
|
+
element,
|
|
4268
|
+
);
|
|
3972
4269
|
return () => {
|
|
3973
4270
|
if (this.scrollElements.get(key) === element) this.scrollElements.delete(key);
|
|
3974
4271
|
};
|
|
3975
4272
|
},
|
|
3976
4273
|
|
|
3977
|
-
|
|
4274
|
+
// Without a key, saves the entry on screen (the unload handler, which may run on a stand-in).
|
|
4275
|
+
saveScrollPosition: function(scrollKey) {
|
|
4276
|
+
if (scrollKey === undefined) {
|
|
4277
|
+
scrollKey = historyScrollKey(
|
|
4278
|
+
this.currentHistoryState,
|
|
4279
|
+
window.location.pathname + window.location.search,
|
|
4280
|
+
);
|
|
4281
|
+
}
|
|
3978
4282
|
try {
|
|
3979
4283
|
sessionStorage.setItem(
|
|
3980
|
-
"farm-scroll-" +
|
|
4284
|
+
"farm-scroll-" + scrollKey,
|
|
3981
4285
|
JSON.stringify({ x: window.scrollX, y: window.scrollY }),
|
|
3982
4286
|
);
|
|
3983
4287
|
for (const [key, element] of this.scrollElements) {
|
|
3984
4288
|
sessionStorage.setItem(
|
|
3985
|
-
scrollElementStorageKey(
|
|
4289
|
+
scrollElementStorageKey(scrollKey, key),
|
|
3986
4290
|
JSON.stringify({ x: element.scrollLeft, y: element.scrollTop }),
|
|
3987
4291
|
);
|
|
3988
4292
|
}
|
|
3989
4293
|
} catch {}
|
|
3990
4294
|
},
|
|
3991
4295
|
|
|
3992
|
-
restoreScrollPosition: function(
|
|
4296
|
+
restoreScrollPosition: function(scrollKey) {
|
|
3993
4297
|
try {
|
|
3994
|
-
const saved = sessionStorage.getItem("farm-scroll-" +
|
|
4298
|
+
const saved = sessionStorage.getItem("farm-scroll-" + scrollKey);
|
|
3995
4299
|
if (saved) {
|
|
3996
4300
|
const position = JSON.parse(saved);
|
|
3997
4301
|
setTimeout(() => window.scrollTo(position.x, position.y), 0);
|
|
3998
4302
|
}
|
|
3999
4303
|
for (const [key, element] of this.scrollElements) {
|
|
4000
|
-
this.restoreScrollElement(
|
|
4304
|
+
this.restoreScrollElement(scrollKey, key, element);
|
|
4001
4305
|
}
|
|
4002
4306
|
} catch {}
|
|
4003
4307
|
},
|
|
4004
4308
|
|
|
4005
|
-
restoreScrollElement: function(
|
|
4309
|
+
restoreScrollElement: function(scrollKey, key, element) {
|
|
4006
4310
|
try {
|
|
4007
|
-
const saved = sessionStorage.getItem(scrollElementStorageKey(
|
|
4311
|
+
const saved = sessionStorage.getItem(scrollElementStorageKey(scrollKey, key));
|
|
4008
4312
|
if (!saved) return;
|
|
4009
4313
|
const position = JSON.parse(saved);
|
|
4010
4314
|
setTimeout(() => {
|
|
@@ -4031,6 +4335,8 @@ const farmRouterReady = [];
|
|
|
4031
4335
|
const farmRouterObserved = new Set();
|
|
4032
4336
|
|
|
4033
4337
|
function loadFarmRouter() {
|
|
4338
|
+
// The router's first navigation needs the route table: fetch both at once.
|
|
4339
|
+
if (!farmRouterLoading) prefetchFarmClientRouteTable();
|
|
4034
4340
|
return farmRouterLoading || (farmRouterLoading = import("./farm-client-router").then(function(module) {
|
|
4035
4341
|
farmLoadedRouter = module.spaRouter;
|
|
4036
4342
|
// The router module installs itself as the global; this object stays it, so a reference taken
|
|
@@ -4271,10 +4577,10 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
4271
4577
|
root,
|
|
4272
4578
|
renderer.componentExtensions ?? []
|
|
4273
4579
|
);
|
|
4274
|
-
const globalsCssPath =
|
|
4580
|
+
const globalsCssPath = path15.join(root, srcDir, "app", "globals.css");
|
|
4275
4581
|
const serverStyleModules = [];
|
|
4276
4582
|
const cssImport = [
|
|
4277
|
-
...
|
|
4583
|
+
...existsSync3(globalsCssPath) ? [globalsCssPath] : [],
|
|
4278
4584
|
...serverStylesheets.filter((stylesheet) => stylesheet !== globalsCssPath)
|
|
4279
4585
|
].map((stylesheet) => {
|
|
4280
4586
|
if (!/\.module\.[a-z]+$/.test(stylesheet)) {
|
|
@@ -4370,7 +4676,7 @@ function isFarmDocsPath() {
|
|
|
4370
4676
|
// Farm.js Client Runtime (no client components)
|
|
4371
4677
|
${cssImport}
|
|
4372
4678
|
${layoutImports}
|
|
4373
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4679
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4374
4680
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4375
4681
|
${clientPluginEntry.imports}
|
|
4376
4682
|
${clientCachePersistence.imports}
|
|
@@ -4446,13 +4752,14 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4446
4752
|
this.cancelActiveNavigation();
|
|
4447
4753
|
return;
|
|
4448
4754
|
}
|
|
4755
|
+
// The entry still on screen: on Back/Forward the URL and history.state already name the destination.
|
|
4756
|
+
const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
|
|
4449
4757
|
if (action === "pop") {
|
|
4450
4758
|
this.currentHistoryIndex = readHistoryIndex(options.popState);
|
|
4451
4759
|
this.currentHistoryState = options.popState;
|
|
4452
4760
|
}
|
|
4453
4761
|
|
|
4454
|
-
|
|
4455
|
-
this.saveScrollPosition(from);
|
|
4762
|
+
this.saveScrollPosition(fromScrollKey);
|
|
4456
4763
|
const navigation = this.startNavigation(from, url, action);
|
|
4457
4764
|
let clientNavigation;
|
|
4458
4765
|
try {
|
|
@@ -4483,7 +4790,7 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4483
4790
|
if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
|
|
4484
4791
|
else window.scrollTo(0, 0);
|
|
4485
4792
|
} else {
|
|
4486
|
-
this.restoreScrollPosition(to);
|
|
4793
|
+
this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
|
|
4487
4794
|
}
|
|
4488
4795
|
});
|
|
4489
4796
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
@@ -4622,7 +4929,7 @@ window.addEventListener("beforeunload", function(event) {
|
|
|
4622
4929
|
event.preventDefault();
|
|
4623
4930
|
event.returnValue = "";
|
|
4624
4931
|
}
|
|
4625
|
-
spaRouter.saveScrollPosition(
|
|
4932
|
+
spaRouter.saveScrollPosition();
|
|
4626
4933
|
});
|
|
4627
4934
|
|
|
4628
4935
|
// Handle popstate (back/forward)
|
|
@@ -4650,10 +4957,13 @@ document.addEventListener("click", function(e) {
|
|
|
4650
4957
|
e.preventDefault();
|
|
4651
4958
|
spaRouter.navigate(href);
|
|
4652
4959
|
});
|
|
4960
|
+
|
|
4961
|
+
// Link anchors on a page that does not hydrate prefetch through the router as Link would.
|
|
4962
|
+
installFarmLinkPrefetch();
|
|
4653
4963
|
`.trim();
|
|
4654
4964
|
}
|
|
4655
4965
|
const imports = [];
|
|
4656
|
-
const
|
|
4966
|
+
const routeLoaders = [];
|
|
4657
4967
|
const routeSlotEntries = [];
|
|
4658
4968
|
const isolatedBoundaryModules = /* @__PURE__ */ new Map();
|
|
4659
4969
|
clientPages.forEach((page) => {
|
|
@@ -4663,16 +4973,11 @@ document.addEventListener("click", function(e) {
|
|
|
4663
4973
|
toImportPath(boundary.modulePath)
|
|
4664
4974
|
);
|
|
4665
4975
|
}
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
${page.hasIsolatedClientBoundaries ? "hasIsolatedClientBoundaries: true," : ""}
|
|
4672
|
-
islandStrategy: ${JSON.stringify(page.islandStrategy)},
|
|
4673
|
-
navigation: "html-fragment",
|
|
4674
|
-
load: ${load},
|
|
4675
|
-
}`);
|
|
4976
|
+
if (page.pageShouldHydrate) {
|
|
4977
|
+
routeLoaders.push(
|
|
4978
|
+
` () => import(${JSON.stringify(toImportPath(page.modulePath))}).then((module) => module.default),`
|
|
4979
|
+
);
|
|
4980
|
+
}
|
|
4676
4981
|
});
|
|
4677
4982
|
const isolatedHydrationEnabled = isolatedBoundaryModules.size > 0;
|
|
4678
4983
|
const serverTreeEnabled = isolatedHydrationEnabled && clientPages.some((page) => page.serverTree);
|
|
@@ -4743,7 +5048,7 @@ ${layoutImports}
|
|
|
4743
5048
|
${rendererClientImports}
|
|
4744
5049
|
${isolatedHydrationImport}
|
|
4745
5050
|
${providerClientCode.imports}
|
|
4746
|
-
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
5051
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4747
5052
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4748
5053
|
import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
|
|
4749
5054
|
${clientPluginEntry.imports}
|
|
@@ -4762,18 +5067,15 @@ setFarmTrailingSlashPreference(${JSON.stringify(trailingSlash)});
|
|
|
4762
5067
|
installChunkErrorRecovery();
|
|
4763
5068
|
${clientCachePersistence.init}
|
|
4764
5069
|
|
|
4765
|
-
//
|
|
4766
|
-
const
|
|
4767
|
-
${
|
|
5070
|
+
// The page modules that hydrate, by their route's \`loader\` index
|
|
5071
|
+
const farmClientRouteLoaders = [
|
|
5072
|
+
${routeLoaders.join("\n")}
|
|
4768
5073
|
];
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
}).map(function(route) {
|
|
4775
|
-
return { path: route.pattern, meta: route };
|
|
4776
|
-
}));` : "const clientPageRouteMatcher = clientRouteMatcher;"}
|
|
5074
|
+
${generateFarmClientRouteTableRuntime({
|
|
5075
|
+
table: clientPages.length > 0,
|
|
5076
|
+
docs: clientPages.some((page) => page.docs),
|
|
5077
|
+
streamNavigations: islandValues
|
|
5078
|
+
})}
|
|
4777
5079
|
${generateClientPageDirectorySource()}
|
|
4778
5080
|
|
|
4779
5081
|
${isolatedHydrationRuntime}
|
|
@@ -5262,6 +5564,8 @@ async function hydrate() {
|
|
|
5262
5564
|
window.__FARM_PPR_HYDRATING__ = true;
|
|
5263
5565
|
await farmClientRuntime.start();
|
|
5264
5566
|
|
|
5567
|
+
// The route table, when the document named no entries for this URL.
|
|
5568
|
+
await farmClientRoutesBoot;
|
|
5265
5569
|
const pathname = window.location.pathname;
|
|
5266
5570
|
const matched = matchRoute(pathname);
|
|
5267
5571
|
${islandValues ? `if (
|
|
@@ -5638,6 +5942,21 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5638
5942
|
return;
|
|
5639
5943
|
}
|
|
5640
5944
|
|
|
5945
|
+
// The first navigation that matches a route waits for the client route table; a prefetch
|
|
5946
|
+
// usually loaded it already (generateFarmClientRouteTableRuntime). Without it (a deployment
|
|
5947
|
+
// that removed it, a network error), a document navigation is the safe fallback.
|
|
5948
|
+
const routeTable = loadFarmClientRouteTable();
|
|
5949
|
+
if (routeTable) {
|
|
5950
|
+
if (farmPrefetchWhileRouteTableLoads && !options.refresh) this.prefetch(url.href);
|
|
5951
|
+
try {
|
|
5952
|
+
await routeTable;
|
|
5953
|
+
} catch (error) {
|
|
5954
|
+
console.warn("[Farm.js] Could not load the client route table; navigating to " + href + " in full.", error);
|
|
5955
|
+
if (action === "push") window.location.assign(url.href);
|
|
5956
|
+
else window.location.replace(url.href);
|
|
5957
|
+
return;
|
|
5958
|
+
}
|
|
5959
|
+
}
|
|
5641
5960
|
const pathname = url.pathname;
|
|
5642
5961
|
const matched = matchRoute(pathname);
|
|
5643
5962
|
const from = this.currentPath;
|
|
@@ -5654,6 +5973,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5654
5973
|
this.cancelActiveNavigation();
|
|
5655
5974
|
return;
|
|
5656
5975
|
}
|
|
5976
|
+
// The entry still on screen: on Back/Forward the URL and history.state already name the destination.
|
|
5977
|
+
const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
|
|
5657
5978
|
if (action === "pop") {
|
|
5658
5979
|
this.currentHistoryIndex = readHistoryIndex(options.popState);
|
|
5659
5980
|
this.currentHistoryState = options.popState;
|
|
@@ -5662,8 +5983,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5662
5983
|
// A route transition invalidates any trigger waiting on the previous DOM boundary.
|
|
5663
5984
|
cancelPendingPageHydration();
|
|
5664
5985
|
this.stopNavigationStream();
|
|
5665
|
-
|
|
5666
|
-
this.saveScrollPosition(from);
|
|
5986
|
+
this.saveScrollPosition(fromScrollKey);
|
|
5667
5987
|
const navigation = this.startNavigation(from, url, action);
|
|
5668
5988
|
// A refresh keeps the islands still on the page (islands mode).
|
|
5669
5989
|
navigation.refresh = options.refresh === true;
|
|
@@ -5832,7 +6152,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5832
6152
|
if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
|
|
5833
6153
|
else window.scrollTo(0, 0);
|
|
5834
6154
|
} else {
|
|
5835
|
-
this.restoreScrollPosition(to);
|
|
6155
|
+
this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
|
|
5836
6156
|
}
|
|
5837
6157
|
await farmClientRuntime.resolveNavigation(clientNavigation);
|
|
5838
6158
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
@@ -6013,6 +6333,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
6013
6333
|
const url = new URL(href, window.location.href);
|
|
6014
6334
|
if (isFarmExternalNavigationURL(url, window.location.origin)) return;
|
|
6015
6335
|
if (isFarmDocsPath(url.pathname)) return;
|
|
6336
|
+
prefetchFarmClientRouteTable();
|
|
6016
6337
|
|
|
6017
6338
|
// A prefetch warms an ordinary future navigation, which reads the bare
|
|
6018
6339
|
// URL key. Carrying the intercept identity here both missed every real
|
|
@@ -6064,6 +6385,9 @@ void farmClientRuntime.start();
|
|
|
6064
6385
|
/*farm-router-start*/
|
|
6065
6386
|
spaRouter.initializeHistory();
|
|
6066
6387
|
window.__FARM_SPA_ROUTER__ = spaRouter;
|
|
6388
|
+
// Link anchors on a page that does not hydrate prefetch through the router as Link would. In
|
|
6389
|
+
// islands mode this runs once the router loads, so a page still loads it only when it needs it.
|
|
6390
|
+
installFarmLinkPrefetch();
|
|
6067
6391
|
/*farm-router-end*/
|
|
6068
6392
|
|
|
6069
6393
|
window.addEventListener("beforeunload", function(event) {
|
|
@@ -6071,7 +6395,7 @@ window.addEventListener("beforeunload", function(event) {
|
|
|
6071
6395
|
event.preventDefault();
|
|
6072
6396
|
event.returnValue = "";
|
|
6073
6397
|
}
|
|
6074
|
-
spaRouter.saveScrollPosition(
|
|
6398
|
+
spaRouter.saveScrollPosition();
|
|
6075
6399
|
});
|
|
6076
6400
|
|
|
6077
6401
|
// Handle popstate (back/forward)
|
|
@@ -6107,11 +6431,11 @@ if (isFarmDocsSearchPage()) {
|
|
|
6107
6431
|
void hydrate();
|
|
6108
6432
|
`.trim();
|
|
6109
6433
|
}
|
|
6110
|
-
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
|
|
6434
|
+
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime, sourceSnapshot) {
|
|
6111
6435
|
const viteBuild = productionVite.build;
|
|
6112
|
-
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
6436
|
+
const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
6113
6437
|
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
6114
|
-
const
|
|
6438
|
+
const fs5 = await import("fs/promises");
|
|
6115
6439
|
const pluginManager = new PluginManager2({
|
|
6116
6440
|
config,
|
|
6117
6441
|
isDev: false,
|
|
@@ -6126,9 +6450,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6126
6450
|
buildLifetime: rendererBuildLifetime
|
|
6127
6451
|
});
|
|
6128
6452
|
if (!hasScopedPostcssConfig) {
|
|
6129
|
-
postcssConfigDir = await
|
|
6130
|
-
await
|
|
6131
|
-
|
|
6453
|
+
postcssConfigDir = await fs5.mkdtemp(path15.join(os.tmpdir(), "farm-postcss-"));
|
|
6454
|
+
await fs5.writeFile(
|
|
6455
|
+
path15.join(postcssConfigDir, "postcss.config.cjs"),
|
|
6132
6456
|
"module.exports = { plugins: [] };\n"
|
|
6133
6457
|
);
|
|
6134
6458
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -6153,7 +6477,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6153
6477
|
fileName: entry.fileName,
|
|
6154
6478
|
sourceType: "static",
|
|
6155
6479
|
staticInfo: entry.staticInfo,
|
|
6156
|
-
data: (await
|
|
6480
|
+
data: (await fs5.readFile(entry.modulePath)).toString("base64")
|
|
6157
6481
|
});
|
|
6158
6482
|
continue;
|
|
6159
6483
|
}
|
|
@@ -6213,10 +6537,11 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6213
6537
|
const appDirs = getFarmAppDirectories(config);
|
|
6214
6538
|
let openAPIReference = null;
|
|
6215
6539
|
if (config.openapi.enabled && config.openapi.route) {
|
|
6216
|
-
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-
|
|
6540
|
+
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-RHB2P35B.mjs");
|
|
6217
6541
|
const openAPIManager = new OpenAPIManager(appDirs, config.openapi, {
|
|
6218
6542
|
mode: "production",
|
|
6219
6543
|
apiBaseURL: config.api.baseURL,
|
|
6544
|
+
routes: () => apiRouteManager.getRoutes().values(),
|
|
6220
6545
|
loadModule: (filePath) => apiRouteManager.loadModule(filePath)
|
|
6221
6546
|
});
|
|
6222
6547
|
const spec = await openAPIManager.generateSpec();
|
|
@@ -6471,7 +6796,15 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6471
6796
|
] : [],
|
|
6472
6797
|
{ ...createReactProductionModePlugin(), enforce: "pre" },
|
|
6473
6798
|
farmServerOnlyEntriesPlugin(),
|
|
6474
|
-
|
|
6799
|
+
farmIslandContainersPlugin(config),
|
|
6800
|
+
farmPlugin(
|
|
6801
|
+
{
|
|
6802
|
+
...config,
|
|
6803
|
+
isolatedClientBoundaryModules,
|
|
6804
|
+
sourceSnapshot
|
|
6805
|
+
},
|
|
6806
|
+
pluginManager
|
|
6807
|
+
),
|
|
6475
6808
|
farmEnvironmentFunctionsPlugin(config),
|
|
6476
6809
|
...hasRuntimeConfigModule ? [
|
|
6477
6810
|
farmStripPlatformConfigPlugin(
|
|
@@ -6537,7 +6870,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6537
6870
|
} finally {
|
|
6538
6871
|
if (postcssConfigDir) {
|
|
6539
6872
|
try {
|
|
6540
|
-
await
|
|
6873
|
+
await fs5.rm(postcssConfigDir, { recursive: true, force: true });
|
|
6541
6874
|
} catch {
|
|
6542
6875
|
}
|
|
6543
6876
|
}
|
|
@@ -6550,7 +6883,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6550
6883
|
}
|
|
6551
6884
|
function readFarmAppPackageIdentity(root) {
|
|
6552
6885
|
try {
|
|
6553
|
-
return JSON.parse(readFileSync(
|
|
6886
|
+
return JSON.parse(readFileSync(path15.join(root, "package.json"), "utf8"));
|
|
6554
6887
|
} catch {
|
|
6555
6888
|
return {};
|
|
6556
6889
|
}
|
|
@@ -7088,34 +7421,37 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7088
7421
|
...hydrationPlanOptions,
|
|
7089
7422
|
serverOwners: resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands"
|
|
7090
7423
|
};
|
|
7091
|
-
const layoutHydrationPlans =
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
isolatedHydrationMode,
|
|
7097
|
-
hydrationPlanCache,
|
|
7098
|
-
{ ...hydrationPlanOptions, serverTreeLayouts: pageHydrationPlanOptions.serverOwners }
|
|
7099
|
-
)
|
|
7100
|
-
}));
|
|
7101
|
-
const markdownPagePlan = createMarkdownPageHydrationPlanner(
|
|
7102
|
-
resolveFarmMdxComponentsModulePath(resolveMdxConfig(config.mdx), config.root),
|
|
7103
|
-
config.root,
|
|
7104
|
-
isolatedHydrationMode,
|
|
7105
|
-
{ ...hydrationPlanOptions, packageReferences: pageHydrationPlanOptions.serverOwners }
|
|
7106
|
-
);
|
|
7107
|
-
const pageHydrationPlans = new Map(
|
|
7108
|
-
pageRoutes.map((route) => [
|
|
7109
|
-
route.modulePath,
|
|
7110
|
-
isFarmMarkdownPageFile(route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
|
|
7111
|
-
route.modulePath,
|
|
7424
|
+
const { layoutHydrationPlans, pageHydrationPlans } = withFarmSourceSnapshot(() => {
|
|
7425
|
+
const layoutHydrationPlans2 = layoutRoutes.map((layout) => ({
|
|
7426
|
+
...layout,
|
|
7427
|
+
hydration: getCachedClientModuleHydrationPlan(
|
|
7428
|
+
layout.modulePath,
|
|
7112
7429
|
config.root,
|
|
7113
7430
|
isolatedHydrationMode,
|
|
7114
7431
|
hydrationPlanCache,
|
|
7115
|
-
pageHydrationPlanOptions
|
|
7432
|
+
{ ...hydrationPlanOptions, serverTreeLayouts: pageHydrationPlanOptions.serverOwners }
|
|
7116
7433
|
)
|
|
7117
|
-
|
|
7118
|
-
|
|
7434
|
+
}));
|
|
7435
|
+
const markdownPagePlan = createMarkdownPageHydrationPlanner(
|
|
7436
|
+
resolveFarmMdxComponentsModulePath(resolveMdxConfig(config.mdx), config.root),
|
|
7437
|
+
config.root,
|
|
7438
|
+
isolatedHydrationMode,
|
|
7439
|
+
{ ...hydrationPlanOptions, packageReferences: pageHydrationPlanOptions.serverOwners }
|
|
7440
|
+
);
|
|
7441
|
+
const pageHydrationPlans2 = new Map(
|
|
7442
|
+
pageRoutes.map((route) => [
|
|
7443
|
+
route.modulePath,
|
|
7444
|
+
isFarmMarkdownPageFile(route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
|
|
7445
|
+
route.modulePath,
|
|
7446
|
+
config.root,
|
|
7447
|
+
isolatedHydrationMode,
|
|
7448
|
+
hydrationPlanCache,
|
|
7449
|
+
pageHydrationPlanOptions
|
|
7450
|
+
)
|
|
7451
|
+
])
|
|
7452
|
+
);
|
|
7453
|
+
return { layoutHydrationPlans: layoutHydrationPlans2, pageHydrationPlans: pageHydrationPlans2 };
|
|
7454
|
+
});
|
|
7119
7455
|
enforceFarmIsolatedHydrationRouteBudget(
|
|
7120
7456
|
layoutHydrationPlans.map((layout) => ({
|
|
7121
7457
|
pattern: layout.pattern,
|
|
@@ -7397,6 +7733,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7397
7733
|
listFarmMCPLlmsTxtLinks,
|
|
7398
7734
|
readFarmLlmsMarkdownFrom,
|
|
7399
7735
|
registerFarmMCPServer,
|
|
7736
|
+
_listFarmRegisteredMCPServerTools,
|
|
7737
|
+
_observeFarmRegisteredMCPResponse,
|
|
7738
|
+
_readFarmRegisteredMCPCalls,
|
|
7400
7739
|
renderFarmLlmsFullTxt,
|
|
7401
7740
|
resolveFarmAgentOrigin,
|
|
7402
7741
|
createFarmLlmsFullRenderer,
|
|
@@ -7438,6 +7777,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7438
7777
|
resolveFarmInstrumentationRuntime,
|
|
7439
7778
|
resolveFarmPreviewDeployment,
|
|
7440
7779
|
resolveFarmWebRequestOrigin,
|
|
7780
|
+
_withFarmTrustedProxyOrigin,
|
|
7441
7781
|
fetchFarmExternalRewrite,
|
|
7442
7782
|
runWithFarmRequestSpan,
|
|
7443
7783
|
createFarmSearchParams,
|
|
@@ -7541,7 +7881,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
7541
7881
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
7542
7882
|
const appMarkdownImport = hasMarkdownPages ? `import { FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS, createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse, isFarmMarkdownPublicSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;\nconst isFarmMarkdownPublicSourceResponse = null;";
|
|
7543
7883
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
7544
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
7884
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path15.isAbsolute(config.mdx.components) ? config.mdx.components : path15.join(config.root, config.mdx.components) : null;
|
|
7545
7885
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
7546
7886
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
7547
7887
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -7712,7 +8052,7 @@ ${instrumentationImport}
|
|
|
7712
8052
|
${imageRuntimeImport}
|
|
7713
8053
|
${imageNodeRuntimeImport}
|
|
7714
8054
|
import { farmFontPreloadHeader } from "virtual:farm-font-runtime";
|
|
7715
|
-
import { isFarmRouteActive } from "@farm.js/core/router";
|
|
8055
|
+
import { createFarmRouter, isFarmRouteActive } from "@farm.js/core/router";
|
|
7716
8056
|
${rendererServerImports}
|
|
7717
8057
|
|
|
7718
8058
|
${routeClientGraphServerRuntime}
|
|
@@ -7763,7 +8103,7 @@ const farmUserConfig = ${configModulePath ? "(FarmUserConfigModule.default || Fa
|
|
|
7763
8103
|
const farmRuntimeConfigs = [${[...layerConfigValues, "farmUserConfig"].join(", ")}].filter(Boolean);
|
|
7764
8104
|
const farmResolvedRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs);
|
|
7765
8105
|
|
|
7766
|
-
function
|
|
8106
|
+
function renderFarmDefault404Page() {
|
|
7767
8107
|
return React.createElement(React.Fragment, null,
|
|
7768
8108
|
React.createElement("style", null, ${JSON.stringify(DEFAULT_NOT_FOUND_STYLES)}),
|
|
7769
8109
|
React.createElement("main", {
|
|
@@ -7789,6 +8129,12 @@ function FarmDefault404Page() {
|
|
|
7789
8129
|
);
|
|
7790
8130
|
}
|
|
7791
8131
|
|
|
8132
|
+
// Renderers that compile their own components (Vue, Svelte) render a plain function as a
|
|
8133
|
+
// component only once it is marked; unmarked, Vue printed this page as "[object Object]".
|
|
8134
|
+
const FarmDefault404Page = typeof React.markFunctionComponent === "function"
|
|
8135
|
+
? React.markFunctionComponent(renderFarmDefault404Page)
|
|
8136
|
+
: renderFarmDefault404Page;
|
|
8137
|
+
|
|
7792
8138
|
/** The app's not-found page, or Farm's, without layouts. */
|
|
7793
8139
|
function createFarmNotFoundElement(pathname) {
|
|
7794
8140
|
const NotFoundPage = hasCustomNotFound && CustomNotFoundComponent ? CustomNotFoundComponent : FarmDefault404Page;
|
|
@@ -8080,7 +8426,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
8080
8426
|
|
|
8081
8427
|
// API routes bundled at build time
|
|
8082
8428
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
8083
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
8429
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path17, methods }) => ({ path: path17, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
8084
8430
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
8085
8431
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
8086
8432
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -8126,7 +8472,17 @@ farmAppManifestInput.guardCoversPath = (path) =>
|
|
|
8126
8472
|
path,
|
|
8127
8473
|
farmLocalAPIBasePath,
|
|
8128
8474
|
);
|
|
8129
|
-
|
|
8475
|
+
${config.docs?.enabled ? `// A docs runtime's MCP server lists its tools when asked over MCP, in process. A build
|
|
8476
|
+
// can't change them, so they are read once.
|
|
8477
|
+
if (farmDocsHandler) {
|
|
8478
|
+
farmAppManifestInput.registeredMCP = (request) =>
|
|
8479
|
+
_listFarmRegisteredMCPServerTools(farmDocsHandler, request, {
|
|
8480
|
+
basePath: ${JSON.stringify(config.basePath)},
|
|
8481
|
+
guardCoversPath: farmAppManifestInput.guardCoversPath,
|
|
8482
|
+
cache: true,
|
|
8483
|
+
});
|
|
8484
|
+
}
|
|
8485
|
+
` : ""}` : ""}
|
|
8130
8486
|
function isFarmLocalAPIPathname(pathname) {
|
|
8131
8487
|
return farmLocalAPIBasePath !== "/" &&
|
|
8132
8488
|
(pathname === farmLocalAPIBasePath ||
|
|
@@ -8210,7 +8566,7 @@ function serializeFarmInlineValue(value) {
|
|
|
8210
8566
|
.replace(/\\u2029/g, "\\\\u2029");
|
|
8211
8567
|
}
|
|
8212
8568
|
|
|
8213
|
-
function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps) {
|
|
8569
|
+
function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps, routePathname) {
|
|
8214
8570
|
const integrationManifest = ${hasRuntimeIntegrationConfig ? "getRegisteredIntegrationAPIManifest()" : "{}"};
|
|
8215
8571
|
const serializedRouteSlots = serializeFarmInlineValue(selectedRouteSlots || []);
|
|
8216
8572
|
const serializedPageProps = serializeFarmInlineValue(pageProps || {});
|
|
@@ -8219,6 +8575,13 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
|
|
|
8219
8575
|
serializeFarmInlineValue(integrationManifest) +
|
|
8220
8576
|
';window.__FARM_ROUTE_SLOTS__=' + serializedRouteSlots +
|
|
8221
8577
|
';window.__FARM_DEPLOYMENT_ID__=' + serializeFarmInlineValue(farmDeploymentId) + ';';
|
|
8578
|
+
// The client boots at the canonical path when the script below moves it there.
|
|
8579
|
+
const bootRoutes = getFarmClientBootRoutes(
|
|
8580
|
+
typeof canonicalPath === "string" && canonicalPath.startsWith("/")
|
|
8581
|
+
? getFarmRoutePathname(canonicalPath.split(/[?#]/)[0])
|
|
8582
|
+
: routePathname
|
|
8583
|
+
);
|
|
8584
|
+
if (bootRoutes) source += 'window.__FARM_CLIENT_ROUTES__=' + serializeFarmInlineValue(bootRoutes) + ';';
|
|
8222
8585
|
if (typeof canonicalPath === "string" && canonicalPath.startsWith("/")) {
|
|
8223
8586
|
const serializedPath = serializeFarmInlineValue(canonicalPath);
|
|
8224
8587
|
source += 'if(location.pathname+location.search!==' + serializedPath + '){' +
|
|
@@ -8309,9 +8672,12 @@ async function farmKeptLayoutsRender(ReactDOMServer, layouts, keptCount, params)
|
|
|
8309
8672
|
if (Layout) element = React.createElement(Layout, { children: element, params });
|
|
8310
8673
|
}
|
|
8311
8674
|
try {
|
|
8675
|
+
// The markup is thrown away, so client components render as plain components, as in a root
|
|
8676
|
+
// that hydrates whole: their props are not encoded for a browser that never receives them.
|
|
8677
|
+
// Server components, guards included, run as usual.
|
|
8312
8678
|
const rendered = await renderFarmElement(
|
|
8313
8679
|
ReactDOMServer,
|
|
8314
|
-
wrapWithFarmIntegrationProviders(element),
|
|
8680
|
+
wrapWithFarmIntegrationProviders(wrapFarmRouteClientGraph(element)),
|
|
8315
8681
|
);
|
|
8316
8682
|
if (rendered.stream) {
|
|
8317
8683
|
const reader = rendered.stream.getReader();
|
|
@@ -9031,6 +9397,9 @@ function createFarmErrorDocument(html, title) {
|
|
|
9031
9397
|
' ' + renderFarmClientEntryScript() + '\\n</body>';
|
|
9032
9398
|
},
|
|
9033
9399
|
);
|
|
9400
|
+
// The charset and viewport a layout's own document leaves out, as on a page and the
|
|
9401
|
+
// not-found page: without the viewport the error page lays out at desktop width on phones.
|
|
9402
|
+
fullHtml = ensureFarmDocumentMeta(fullHtml, renderViewportHead(undefined));
|
|
9034
9403
|
return fullHtml.trim().startsWith("<!DOCTYPE")
|
|
9035
9404
|
? fullHtml
|
|
9036
9405
|
: "<!DOCTYPE html>\\n" + fullHtml;
|
|
@@ -9045,6 +9414,8 @@ const farmClientModulePreloads = (() => {
|
|
|
9045
9414
|
return null;
|
|
9046
9415
|
}
|
|
9047
9416
|
})();
|
|
9417
|
+
${generateFarmClientBootRoutesServerSource(`"${FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER}"`)}
|
|
9418
|
+
|
|
9048
9419
|
const farmClientEntryPreloadTags = farmClientModulePreloads
|
|
9049
9420
|
? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
|
|
9050
9421
|
: "";
|
|
@@ -10077,7 +10448,7 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
10077
10448
|
: html.replace(/<[/]head>/i, clientStylesheet + "</head>");
|
|
10078
10449
|
}
|
|
10079
10450
|
if (!html.includes('id="__farm_route_slots_data__"')) {
|
|
10080
|
-
html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript() + "\\n</body>"; });
|
|
10451
|
+
html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript(undefined, undefined, undefined, pathname) + "\\n</body>"; });
|
|
10081
10452
|
}
|
|
10082
10453
|
if (!html.includes('src="/__farm_client_js_src__"')) {
|
|
10083
10454
|
html = html.replace(
|
|
@@ -10496,7 +10867,13 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10496
10867
|
const owned = getFarmAppOwnedDocsEnginePaths(config.agent, applicationMetadataRoutes);
|
|
10497
10868
|
return owned.length ? ` && !${JSON.stringify(owned)}.includes(normalizeRuntimePath(routePathname))` : "";
|
|
10498
10869
|
})()}) {
|
|
10499
|
-
const
|
|
10870
|
+
const farmDocsRequest = cloneFarmRequestWithContext(request);
|
|
10871
|
+
// Tool calls to a docs runtime's MCP server emit mcp.tool.complete, as @farm.js/mcp's do.
|
|
10872
|
+
const farmRegisteredMCPCalls = await _readFarmRegisteredMCPCalls(
|
|
10873
|
+
farmDocsRequest,
|
|
10874
|
+
${JSON.stringify(config.basePath)},
|
|
10875
|
+
);
|
|
10876
|
+
const docsResponse = await farmDocsHandler(farmDocsRequest);
|
|
10500
10877
|
if (docsResponse) {${hasInfraAnalyticsRuntime ? `
|
|
10501
10878
|
const farmAnalyticsRoute = adapterContext?.[farmRouteLabelSlot];
|
|
10502
10879
|
if (farmAnalyticsRoute) {
|
|
@@ -10507,7 +10884,19 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10507
10884
|
}` : ""}
|
|
10508
10885
|
if (!docsResponse.headers.get("content-type")?.toLowerCase().includes("text/html")) {
|
|
10509
10886
|
return applyProductionMiddlewareHeaders(
|
|
10510
|
-
withFarmDocsRequestCache(
|
|
10887
|
+
withFarmDocsRequestCache(
|
|
10888
|
+
_observeFarmRegisteredMCPResponse(
|
|
10889
|
+
docsResponse,
|
|
10890
|
+
farmRegisteredMCPCalls,
|
|
10891
|
+
typeof adapterContext?.waitUntil === "function"
|
|
10892
|
+
? adapterContext.waitUntil.bind(adapterContext)
|
|
10893
|
+
: undefined,
|
|
10894
|
+
),
|
|
10895
|
+
request,
|
|
10896
|
+
farmLocaleResolution,
|
|
10897
|
+
middlewareData,
|
|
10898
|
+
middlewareContext,
|
|
10899
|
+
),
|
|
10511
10900
|
middlewareHeaders,
|
|
10512
10901
|
);
|
|
10513
10902
|
}
|
|
@@ -10803,7 +11192,9 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10803
11192
|
if (matchedRoute && request.method === "POST") {
|
|
10804
11193
|
const actionResponse = await _runWithMiddlewareData(middlewareData || {}, () =>
|
|
10805
11194
|
_runWithMiddlewareContext(middlewareContext || {}, () =>
|
|
10806
|
-
handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl
|
|
11195
|
+
handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl, {
|
|
11196
|
+
trustProxy: farmServerConfig.trustProxy === true,
|
|
11197
|
+
})
|
|
10807
11198
|
)
|
|
10808
11199
|
);
|
|
10809
11200
|
if (actionResponse) return applyProductionMiddlewareHeaders(actionResponse, middlewareHeaders);
|
|
@@ -11537,7 +11928,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11537
11928
|
return ' ' + renderFarmClientBootstrapScript(
|
|
11538
11929
|
pageProps.__farmCanonicalPath,
|
|
11539
11930
|
farmDeferredData.data.slots,
|
|
11540
|
-
farmDeferredData.data.page
|
|
11931
|
+
farmDeferredData.data.page,
|
|
11932
|
+
routePathname
|
|
11541
11933
|
) + '\\n' +
|
|
11542
11934
|
' ' + renderFarmClientEntryScript(early) + '\\n';
|
|
11543
11935
|
};
|
|
@@ -11694,7 +12086,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11694
12086
|
() => ' ' + renderFarmClientBootstrapScript(
|
|
11695
12087
|
pageProps.__farmCanonicalPath,
|
|
11696
12088
|
farmDeferredData.data.slots,
|
|
11697
|
-
farmDeferredData.data.page
|
|
12089
|
+
farmDeferredData.data.page,
|
|
12090
|
+
routePathname
|
|
11698
12091
|
) + renderFarmDeferredDataScript(farmDeferredData.records) + '\\n' +
|
|
11699
12092
|
' ' + farmEntryScript + '\\n</body>',
|
|
11700
12093
|
);
|
|
@@ -11712,7 +12105,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11712
12105
|
</head>
|
|
11713
12106
|
<body>
|
|
11714
12107
|
<div id="root">\${html}</div>
|
|
11715
|
-
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
|
|
12108
|
+
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page, routePathname)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
|
|
11716
12109
|
\${farmEntryScript}
|
|
11717
12110
|
</body>
|
|
11718
12111
|
</html>\`;
|
|
@@ -12049,7 +12442,7 @@ ${farmRendererDisabled ? `
|
|
|
12049
12442
|
.replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
|
|
12050
12443
|
.replace(
|
|
12051
12444
|
/<\\/body>/i,
|
|
12052
|
-
() => ' ' + renderFarmClientBootstrapScript() + '\\n' +
|
|
12445
|
+
() => ' ' + renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname) + '\\n' +
|
|
12053
12446
|
' ' + renderFarmClientEntryScript() + '\\n</body>',
|
|
12054
12447
|
);
|
|
12055
12448
|
fullHtml = ensureFarmDocumentMeta(fullHtml, notFoundMetadata.viewport);
|
|
@@ -12069,7 +12462,7 @@ ${farmRendererDisabled ? `
|
|
|
12069
12462
|
</head>
|
|
12070
12463
|
<body>
|
|
12071
12464
|
<div id="root">\${html}</div>
|
|
12072
|
-
\${renderFarmClientBootstrapScript()}
|
|
12465
|
+
\${renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname)}
|
|
12073
12466
|
\${renderFarmClientEntryScript()}
|
|
12074
12467
|
</body>
|
|
12075
12468
|
</html>\`;
|
|
@@ -12206,7 +12599,10 @@ export async function fetch(request, context) {${imageRuntime === "none" ? "" :
|
|
|
12206
12599
|
return farmNoindexPreview ? applyFarmPreviewRobotsTag(response) : response;` : ""}
|
|
12207
12600
|
}
|
|
12208
12601
|
|
|
12209
|
-
async function handleFarmFetch(request, context) {
|
|
12602
|
+
async function handleFarmFetch(request, context) {${config.server.trustProxy ? `
|
|
12603
|
+
// server.trustProxy: middleware, pages, and API routes read the URL the visitor requested,
|
|
12604
|
+
// at the origin the trusted proxy forwards, as in development.
|
|
12605
|
+
request = _withFarmTrustedProxyOrigin(request);` : ""}
|
|
12210
12606
|
const healthResponse = await farmProductionLifecycle.handleHealthRequest(request);
|
|
12211
12607
|
if (healthResponse) return healthResponse;
|
|
12212
12608
|
|
|
@@ -12354,17 +12750,22 @@ function escapeRoutePattern(value) {
|
|
|
12354
12750
|
return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
12355
12751
|
}
|
|
12356
12752
|
function middlewarePatternMatches(pattern, pathname) {
|
|
12753
|
+
return createMiddlewarePatternMatcher(pattern)(pathname);
|
|
12754
|
+
}
|
|
12755
|
+
function createMiddlewarePatternMatcher(pattern) {
|
|
12357
12756
|
if (pattern instanceof RegExp) {
|
|
12358
|
-
|
|
12359
|
-
|
|
12757
|
+
return (pathname) => {
|
|
12758
|
+
pattern.lastIndex = 0;
|
|
12759
|
+
return pattern.test(pathname);
|
|
12760
|
+
};
|
|
12360
12761
|
}
|
|
12361
|
-
if (pattern === "*" || pattern === "/(.*)") return true;
|
|
12762
|
+
if (pattern === "*" || pattern === "/(.*)") return () => true;
|
|
12362
12763
|
if (pattern.endsWith("(.*)")) {
|
|
12363
12764
|
const prefix = pattern.slice(0, -4);
|
|
12364
|
-
return pathname === prefix || pathname.startsWith(`${prefix}/`);
|
|
12765
|
+
return (pathname) => pathname === prefix || pathname.startsWith(`${prefix}/`);
|
|
12365
12766
|
}
|
|
12366
12767
|
const segments = pattern.split("/").filter(Boolean);
|
|
12367
|
-
if (segments.length === 0) return pathname === "/";
|
|
12768
|
+
if (segments.length === 0) return (pathname) => pathname === "/";
|
|
12368
12769
|
const expression = segments.map((segment) => {
|
|
12369
12770
|
if (segment === "**") return "(?:/.*)?";
|
|
12370
12771
|
if (segment === "*") return "/[^/]+";
|
|
@@ -12376,7 +12777,8 @@ function middlewarePatternMatches(pattern, pathname) {
|
|
|
12376
12777
|
if (segment.startsWith(":") || /^\[.+\]$/.test(segment)) return "/[^/]+";
|
|
12377
12778
|
return `/${escapeRoutePattern(segment).replace(/\\\*/g, "[^/]*")}`;
|
|
12378
12779
|
}).join("");
|
|
12379
|
-
|
|
12780
|
+
const regex = new RegExp(`^${expression}/?$`);
|
|
12781
|
+
return (pathname) => regex.test(pathname);
|
|
12380
12782
|
}
|
|
12381
12783
|
function routePatternSpecificity(pattern) {
|
|
12382
12784
|
return pattern.split("/").filter(Boolean).reduce((score, segment) => {
|
|
@@ -12391,8 +12793,18 @@ function routePatternSpecificity(pattern) {
|
|
|
12391
12793
|
function getEffectiveRouteRule(config, pathname) {
|
|
12392
12794
|
return Object.entries(config.routeRules).filter(([pattern]) => middlewarePatternMatches(pattern, pathname)).sort(([left], [right]) => routePatternSpecificity(left) - routePatternSpecificity(right)).reduce((resolved, [, rule]) => Object.assign(resolved, rule), {});
|
|
12393
12795
|
}
|
|
12796
|
+
var manifestPageMatchers = /* @__PURE__ */ new WeakMap();
|
|
12394
12797
|
function getManifestPageEntry(manifest, pathname) {
|
|
12395
|
-
|
|
12798
|
+
let pages = manifestPageMatchers.get(manifest.routes);
|
|
12799
|
+
if (!pages) {
|
|
12800
|
+
pages = manifest.routes.filter((entry) => entry.kind === "page").map((entry) => ({
|
|
12801
|
+
entry,
|
|
12802
|
+
matches: createMiddlewarePatternMatcher(entry.pattern),
|
|
12803
|
+
specificity: getRoutePatternSpecificity(entry.pattern)
|
|
12804
|
+
})).sort((left, right) => compareRouteSpecificity(left.specificity, right.specificity)).map(({ entry, matches }) => ({ entry, matches }));
|
|
12805
|
+
manifestPageMatchers.set(manifest.routes, pages);
|
|
12806
|
+
}
|
|
12807
|
+
return pages.find((page) => page.matches(pathname))?.entry;
|
|
12396
12808
|
}
|
|
12397
12809
|
function withFarmEdgeGuardedPrerenderHeaders(headers, edgeGuarded) {
|
|
12398
12810
|
if (!edgeGuarded) return headers;
|
|
@@ -12507,8 +12919,8 @@ function hasFarmNitroCacheRouteRule(routeRules) {
|
|
|
12507
12919
|
return swr !== void 0 && swr !== false || cache !== void 0 && cache !== false || !!headers && typeof headers === "object" && Object.keys(headers).length > 0;
|
|
12508
12920
|
});
|
|
12509
12921
|
}
|
|
12510
|
-
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager) {
|
|
12511
|
-
const [
|
|
12922
|
+
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager, markdownPrecompiledPages) {
|
|
12923
|
+
const [fs5, nitroBuilderResult] = await Promise.all([
|
|
12512
12924
|
import("fs/promises"),
|
|
12513
12925
|
nitroBuilderResultPromise
|
|
12514
12926
|
]);
|
|
@@ -12517,8 +12929,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12517
12929
|
const isVercel = preset === "vercel";
|
|
12518
12930
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
12519
12931
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
12520
|
-
const runtimeServerOutputDir = isVercel ?
|
|
12521
|
-
const ssrOutputDir =
|
|
12932
|
+
const runtimeServerOutputDir = isVercel ? path15.join(outputDir, "functions", "__nitro.func") : path15.join(outputDir, "server");
|
|
12933
|
+
const ssrOutputDir = path15.join(root, distDir, "ssr");
|
|
12522
12934
|
const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
|
|
12523
12935
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
12524
12936
|
(image) => image.sourceType === "module"
|
|
@@ -12634,21 +13046,34 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12634
13046
|
"Cloudflare Pages does not install Cron Triggers. Use the cloudflare-module preset or an external scheduler with .farm/cron-manifest.json."
|
|
12635
13047
|
);
|
|
12636
13048
|
}
|
|
12637
|
-
const
|
|
13049
|
+
const portableScheduledTasks = mergeScheduledTasks(
|
|
13050
|
+
farmWorkflows.scheduledTasks,
|
|
13051
|
+
farmCron.scheduledTasks
|
|
13052
|
+
);
|
|
13053
|
+
const scheduledTasks = preset.startsWith("cloudflare") ? toFarmCronCloudflareScheduledTasks(portableScheduledTasks) : portableScheduledTasks;
|
|
12638
13054
|
const cloudflareCronConfig = farmCron.provider === "host" ? createFarmCronCloudflareConfig(farmCron.jobs) : void 0;
|
|
12639
|
-
const [
|
|
13055
|
+
const [
|
|
13056
|
+
clientCssHref,
|
|
13057
|
+
clientJsSrc,
|
|
13058
|
+
clientBootSrc,
|
|
13059
|
+
docsModulePreloads,
|
|
13060
|
+
clientModulePreloads,
|
|
13061
|
+
clientRouteTable
|
|
13062
|
+
] = await Promise.all([
|
|
12640
13063
|
resolveHashedClientCssHref(clientOutputDir),
|
|
12641
13064
|
resolveHashedClientJsSrc(clientOutputDir),
|
|
12642
13065
|
resolveClientBootSrc(clientOutputDir),
|
|
12643
|
-
readFarmDocsModulePreloads(
|
|
12644
|
-
readFarmClientModulePreloads(
|
|
13066
|
+
readFarmDocsModulePreloads(path15.join(root, distDir)),
|
|
13067
|
+
readFarmClientModulePreloads(path15.join(root, distDir)),
|
|
13068
|
+
readFarmClientRouteTable(path15.join(root, distDir))
|
|
12645
13069
|
]);
|
|
12646
13070
|
let nativeStylesheets;
|
|
12647
13071
|
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
12648
13072
|
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
13073
|
+
const encodedClientRouteTable = encodeFarmBuildJSONPlaceholder(clientRouteTable);
|
|
12649
13074
|
const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
|
|
12650
13075
|
await finalizeFarmMobileClient({
|
|
12651
|
-
buildDir:
|
|
13076
|
+
buildDir: path15.join(root, distDir),
|
|
12652
13077
|
clientOutputDir,
|
|
12653
13078
|
webEntry: clientJsSrc,
|
|
12654
13079
|
webBoot: clientBootSrc,
|
|
@@ -12667,6 +13092,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12667
13092
|
if (output.code.includes(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER)) {
|
|
12668
13093
|
output.code = output.code.split(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER).join(encodedClientModulePreloads);
|
|
12669
13094
|
}
|
|
13095
|
+
if (output.code.includes(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER)) {
|
|
13096
|
+
output.code = output.code.split(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER).join(encodedClientRouteTable);
|
|
13097
|
+
}
|
|
12670
13098
|
if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
|
|
12671
13099
|
output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
|
|
12672
13100
|
}
|
|
@@ -12684,15 +13112,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12684
13112
|
output.code = output.code.split(JSON.stringify(FARM_NATIVE_STYLESHEETS_PLACEHOLDER)).join(JSON.stringify(JSON.stringify(nativeStylesheets)));
|
|
12685
13113
|
}
|
|
12686
13114
|
}
|
|
12687
|
-
await
|
|
13115
|
+
await fs5.mkdir(ssrOutputDir, { recursive: true });
|
|
12688
13116
|
await Promise.all(
|
|
12689
13117
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
12690
|
-
const filePath =
|
|
12691
|
-
await
|
|
12692
|
-
await
|
|
13118
|
+
const filePath = path15.join(ssrOutputDir, fileName);
|
|
13119
|
+
await fs5.mkdir(path15.dirname(filePath), { recursive: true });
|
|
13120
|
+
await fs5.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
12693
13121
|
})
|
|
12694
13122
|
);
|
|
12695
|
-
const nitroEntryPath =
|
|
13123
|
+
const nitroEntryPath = path15.join(ssrOutputDir, "nitro-entry.mjs");
|
|
12696
13124
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
12697
13125
|
const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
|
|
12698
13126
|
const nitroEntryCode = `
|
|
@@ -12898,7 +13326,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12898
13326
|
})
|
|
12899
13327
|
}` : ""}
|
|
12900
13328
|
`.trim();
|
|
12901
|
-
await
|
|
13329
|
+
await fs5.writeFile(nitroEntryPath, nitroEntryCode);
|
|
12902
13330
|
const desktopServerEntry = config.desktop ? {
|
|
12903
13331
|
basePath: config.basePath === "/" ? "" : config.basePath || "",
|
|
12904
13332
|
guardModule: "@farm.js/core/internal/desktop-guard"
|
|
@@ -12909,21 +13337,21 @@ function toFarmNodeResponse(request, response) {
|
|
|
12909
13337
|
`[Farm] A desktop build runs its server in the shell, so it needs the "bun" or "node-server" preset, not "${preset}".`
|
|
12910
13338
|
);
|
|
12911
13339
|
}
|
|
12912
|
-
await
|
|
12913
|
-
|
|
13340
|
+
await fs5.writeFile(
|
|
13341
|
+
path15.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
|
|
12914
13342
|
FARM_DESKTOP_ENV_MODULE_SOURCE
|
|
12915
13343
|
);
|
|
12916
13344
|
}
|
|
12917
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
13345
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path15.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
12918
13346
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
12919
|
-
await
|
|
12920
|
-
|
|
13347
|
+
await fs5.writeFile(
|
|
13348
|
+
path15.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
12921
13349
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
12922
13350
|
);
|
|
12923
|
-
await
|
|
13351
|
+
await fs5.writeFile(
|
|
12924
13352
|
farmNodeServerEntryPath,
|
|
12925
13353
|
createFarmNodeServerEntry({
|
|
12926
|
-
nitroEntryFile:
|
|
13354
|
+
nitroEntryFile: path15.basename(nitroEntryPath),
|
|
12927
13355
|
nodeAdapterModule,
|
|
12928
13356
|
server: config.server,
|
|
12929
13357
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
|
|
@@ -12931,12 +13359,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
12931
13359
|
})
|
|
12932
13360
|
);
|
|
12933
13361
|
}
|
|
12934
|
-
const farmBunServerEntryPath = preset === "bun" ?
|
|
13362
|
+
const farmBunServerEntryPath = preset === "bun" ? path15.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
|
|
12935
13363
|
if (farmBunServerEntryPath) {
|
|
12936
|
-
await
|
|
13364
|
+
await fs5.writeFile(
|
|
12937
13365
|
farmBunServerEntryPath,
|
|
12938
13366
|
createFarmBunServerEntry({
|
|
12939
|
-
nitroEntryFile:
|
|
13367
|
+
nitroEntryFile: path15.basename(nitroEntryPath),
|
|
12940
13368
|
bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
|
|
12941
13369
|
server: config.server,
|
|
12942
13370
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
|
|
@@ -12944,18 +13372,18 @@ function toFarmNodeResponse(request, response) {
|
|
|
12944
13372
|
})
|
|
12945
13373
|
);
|
|
12946
13374
|
}
|
|
12947
|
-
const farmNetlifyEntryPath = preset === "netlify" ?
|
|
13375
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path15.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
12948
13376
|
if (farmNetlifyEntryPath) {
|
|
12949
|
-
await
|
|
13377
|
+
await fs5.writeFile(
|
|
12950
13378
|
farmNetlifyEntryPath,
|
|
12951
13379
|
createFarmNetlifyEntry({
|
|
12952
13380
|
nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
|
|
12953
13381
|
})
|
|
12954
13382
|
);
|
|
12955
13383
|
}
|
|
12956
|
-
const farmCloudflareEnvPath = preset === "cloudflare-pages" ?
|
|
13384
|
+
const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path15.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
|
|
12957
13385
|
if (farmCloudflareEnvPath) {
|
|
12958
|
-
await
|
|
13386
|
+
await fs5.writeFile(
|
|
12959
13387
|
farmCloudflareEnvPath,
|
|
12960
13388
|
`export default function farmCloudflareEnv(event) {
|
|
12961
13389
|
const env = event.req.runtime?.cloudflare?.env
|
|
@@ -13027,7 +13455,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13027
13455
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
13028
13456
|
serverDir: false,
|
|
13029
13457
|
serverEntry: false,
|
|
13030
|
-
buildDir:
|
|
13458
|
+
buildDir: path15.join(root, distDir, ".nitro"),
|
|
13031
13459
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
13032
13460
|
compatibilityDate: "2024-12-01",
|
|
13033
13461
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -13051,7 +13479,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
13051
13479
|
// answered independently, as by the production server, so keeping several
|
|
13052
13480
|
// in flight overlaps the worker's rendering with this thread's per-route work.
|
|
13053
13481
|
concurrency: Math.min(os.availableParallelism(), 8),
|
|
13054
|
-
routes: prerenderRoutes.map(toPrerenderPublicPath)
|
|
13482
|
+
routes: prerenderRoutes.map(toPrerenderPublicPath),
|
|
13483
|
+
// Cloudflare's asset server answers a directory index (about/index.html) at the
|
|
13484
|
+
// trailing-slash URL and redirects the other spelling to it, so a page is written as
|
|
13485
|
+
// about.html unless trailingSlash asks for the slash, as Nitro's Netlify and Vercel
|
|
13486
|
+
// presets already write it.
|
|
13487
|
+
...preset.startsWith("cloudflare") ? { autoSubfolderIndex: config.trailingSlash === true } : {}
|
|
13055
13488
|
}
|
|
13056
13489
|
} : {},
|
|
13057
13490
|
experimental: {
|
|
@@ -13116,7 +13549,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13116
13549
|
if (pluginManager) {
|
|
13117
13550
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
13118
13551
|
}
|
|
13119
|
-
const expectedServerDir =
|
|
13552
|
+
const expectedServerDir = path15.join(outputDir, "server");
|
|
13120
13553
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
13121
13554
|
(key) => key !== "external" && key !== "plugins"
|
|
13122
13555
|
);
|
|
@@ -13131,10 +13564,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
13131
13564
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
13132
13565
|
const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && Boolean(
|
|
13133
13566
|
nitroConfig.handlers?.some(
|
|
13134
|
-
(handler) =>
|
|
13567
|
+
(handler) => path15.resolve(handler?.handler || "") === nitroEntryPath
|
|
13135
13568
|
)
|
|
13136
13569
|
);
|
|
13137
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms &&
|
|
13570
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path15.resolve(nitroConfig.output?.serverDir || "") === path15.resolve(expectedServerDir);
|
|
13138
13571
|
const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
|
|
13139
13572
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
13140
13573
|
if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
|
|
@@ -13172,6 +13605,21 @@ function toFarmNodeResponse(request, response) {
|
|
|
13172
13605
|
const orderOf = (route) => prerenderOrder.get(route) ?? Number.MAX_SAFE_INTEGER;
|
|
13173
13606
|
prerenderedRoutes.sort((a, b) => orderOf(a.route) - orderOf(b.route));
|
|
13174
13607
|
});
|
|
13608
|
+
const prerenderPagePaths = new Set(prerenderRoutes.map(toPrerenderPublicPath));
|
|
13609
|
+
let skippedNonHtmlPrerenderRoute = false;
|
|
13610
|
+
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
13611
|
+
if (route.error || !prerenderPagePaths.has(route.route)) return;
|
|
13612
|
+
if (route.contentType?.toLowerCase().includes("html")) return;
|
|
13613
|
+
route.skip = true;
|
|
13614
|
+
skippedNonHtmlPrerenderRoute = true;
|
|
13615
|
+
const configuredRule = configuredNitroRouteRules[route.route];
|
|
13616
|
+
if (configuredRule) nitroInstance.options.routeRules[route.route] = configuredRule;
|
|
13617
|
+
else delete nitroInstance.options.routeRules[route.route];
|
|
13618
|
+
logger.info(`\u21AA Keeping SSG route ${route.route} server-handled (it does not render HTML)`);
|
|
13619
|
+
});
|
|
13620
|
+
nitroInstance.hooks.hook("prerender:done", () => {
|
|
13621
|
+
if (skippedNonHtmlPrerenderRoute) nitroInstance.routing.sync();
|
|
13622
|
+
});
|
|
13175
13623
|
if (config.md?.enabled) {
|
|
13176
13624
|
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
13177
13625
|
if (!route.contents || !route.contentType?.toLowerCase().includes("html")) return;
|
|
@@ -13224,7 +13672,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
13224
13672
|
const configuredPlugins = rollupConfig.plugins;
|
|
13225
13673
|
rollupConfig.plugins = [
|
|
13226
13674
|
...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [],
|
|
13227
|
-
createPrerenderRuntimeResolverPlugin(config.root)
|
|
13675
|
+
createPrerenderRuntimeResolverPlugin(config.root),
|
|
13676
|
+
...markdownPrecompiledPages ? [createPrerenderMarkdownPagesPlugin(markdownPrecompiledPages)] : []
|
|
13228
13677
|
];
|
|
13229
13678
|
});
|
|
13230
13679
|
});
|
|
@@ -13240,8 +13689,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
13240
13689
|
};
|
|
13241
13690
|
prerendererConfig.output = {
|
|
13242
13691
|
...prerendererConfig.output,
|
|
13243
|
-
serverDir:
|
|
13244
|
-
prerendererConfig.buildDir ??
|
|
13692
|
+
serverDir: path15.join(
|
|
13693
|
+
prerendererConfig.buildDir ?? path15.join(root, distDir, ".nitro"),
|
|
13245
13694
|
"prerender"
|
|
13246
13695
|
)
|
|
13247
13696
|
};
|
|
@@ -13260,11 +13709,11 @@ function toFarmNodeResponse(request, response) {
|
|
|
13260
13709
|
const prerenderServerDir = prerenderer.options.output.serverDir;
|
|
13261
13710
|
await copyPrebuiltSSRBundle(
|
|
13262
13711
|
ssrBundle,
|
|
13263
|
-
|
|
13712
|
+
path15.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
13264
13713
|
null,
|
|
13265
|
-
|
|
13714
|
+
fs5
|
|
13266
13715
|
);
|
|
13267
|
-
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile,
|
|
13716
|
+
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs5);
|
|
13268
13717
|
});
|
|
13269
13718
|
});
|
|
13270
13719
|
}
|
|
@@ -13298,7 +13747,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13298
13747
|
else process.env[FARM_PRERENDER_ENV] = previousPrerender;
|
|
13299
13748
|
}
|
|
13300
13749
|
}
|
|
13301
|
-
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir,
|
|
13750
|
+
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs5, preset) : Promise.resolve(null);
|
|
13302
13751
|
const prebuiltSSRFilesPromise = canReusePrebuiltSSR ? prepareSSRBundleFiles(
|
|
13303
13752
|
ssrBundle,
|
|
13304
13753
|
shouldMinify ? { keepNames: keepServerNames, target: "node18" } : null
|
|
@@ -13311,7 +13760,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13311
13760
|
await nitroInstance.close();
|
|
13312
13761
|
if (nitroBuildResult.status === "rejected") {
|
|
13313
13762
|
if (sharpRuntimeStageResult.status === "fulfilled" && sharpRuntimeStageResult.value) {
|
|
13314
|
-
await
|
|
13763
|
+
await fs5.rm(sharpRuntimeStageResult.value.stageDir, {
|
|
13315
13764
|
recursive: true,
|
|
13316
13765
|
force: true
|
|
13317
13766
|
});
|
|
@@ -13324,20 +13773,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
13324
13773
|
if (prebuiltSSRFilesResult.status === "rejected") {
|
|
13325
13774
|
throw prebuiltSSRFilesResult.reason;
|
|
13326
13775
|
}
|
|
13327
|
-
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir,
|
|
13776
|
+
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs5, preset) : null);
|
|
13328
13777
|
const runtimeCopyPromise = (async () => {
|
|
13329
13778
|
if (stagedSharpRuntime) {
|
|
13330
|
-
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir,
|
|
13779
|
+
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs5);
|
|
13331
13780
|
}
|
|
13332
13781
|
if (useExternalMetadataImageRuntime) {
|
|
13333
|
-
await copyMetadataImageRuntime(root, runtimeServerOutputDir,
|
|
13782
|
+
await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs5);
|
|
13334
13783
|
}
|
|
13335
13784
|
})();
|
|
13336
13785
|
const copyResults = await Promise.allSettled([
|
|
13337
13786
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
13338
13787
|
prebuiltSSRFilesResult.value,
|
|
13339
|
-
|
|
13340
|
-
|
|
13788
|
+
path15.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
13789
|
+
fs5
|
|
13341
13790
|
) : Promise.resolve(),
|
|
13342
13791
|
runtimeCopyPromise
|
|
13343
13792
|
]);
|
|
@@ -13346,17 +13795,17 @@ function toFarmNodeResponse(request, response) {
|
|
|
13346
13795
|
);
|
|
13347
13796
|
if (failedCopy) throw failedCopy.reason;
|
|
13348
13797
|
if (canReusePrebuiltSSR) {
|
|
13349
|
-
await registerPrebuiltSSRPackageImport(
|
|
13798
|
+
await registerPrebuiltSSRPackageImport(path15.join(outputDir, "server"), ssrEntryFile, fs5);
|
|
13350
13799
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
13351
13800
|
}
|
|
13352
13801
|
if (useRolldownBuilder) {
|
|
13353
13802
|
logger.info("\u26A1 Built the Node adapter with Rolldown");
|
|
13354
13803
|
}
|
|
13355
13804
|
if (preset === "node-server" && !desktopServerEntry) {
|
|
13356
|
-
await installFarmCompileCacheLauncher(
|
|
13805
|
+
await installFarmCompileCacheLauncher(path15.join(outputDir, "server"), fs5);
|
|
13357
13806
|
}
|
|
13358
13807
|
if (preset.startsWith("cloudflare")) {
|
|
13359
|
-
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir,
|
|
13808
|
+
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs5);
|
|
13360
13809
|
}
|
|
13361
13810
|
if (pluginManager) {
|
|
13362
13811
|
await pluginManager.runHookParallel("afterNitroBuild", {
|
|
@@ -13370,13 +13819,13 @@ function toFarmNodeResponse(request, response) {
|
|
|
13370
13819
|
await postProcessVercelOutput(
|
|
13371
13820
|
root,
|
|
13372
13821
|
outputDir,
|
|
13373
|
-
|
|
13822
|
+
fs5,
|
|
13374
13823
|
config,
|
|
13375
13824
|
farmWorkflows,
|
|
13376
13825
|
routeRuntimeManifest,
|
|
13377
13826
|
farmCron.provider === "host" ? farmCron.jobs : [],
|
|
13378
13827
|
{
|
|
13379
|
-
buildDir:
|
|
13828
|
+
buildDir: path15.join(root, distDir),
|
|
13380
13829
|
middlewareRoutes: edgeMiddlewareRoutes,
|
|
13381
13830
|
guardedPages: edgeGuardedPrerenderRoutes
|
|
13382
13831
|
},
|
|
@@ -13390,19 +13839,19 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
13390
13839
|
return {
|
|
13391
13840
|
dir: outputDir,
|
|
13392
13841
|
...preset === "node-server" ? {
|
|
13393
|
-
serverDir:
|
|
13394
|
-
publicDir:
|
|
13842
|
+
serverDir: path15.join(outputDir, "server"),
|
|
13843
|
+
publicDir: path15.join(outputDir, "public")
|
|
13395
13844
|
} : isVercel ? {
|
|
13396
|
-
serverDir:
|
|
13397
|
-
publicDir:
|
|
13845
|
+
serverDir: path15.join(outputDir, "functions", "__nitro.func"),
|
|
13846
|
+
publicDir: path15.join(outputDir, "static")
|
|
13398
13847
|
} : {}
|
|
13399
13848
|
};
|
|
13400
13849
|
}
|
|
13401
|
-
async function populateCloudflareProcessEnv(serverDir,
|
|
13402
|
-
const wranglerPath =
|
|
13850
|
+
async function populateCloudflareProcessEnv(serverDir, fs5) {
|
|
13851
|
+
const wranglerPath = path15.join(serverDir, "wrangler.json");
|
|
13403
13852
|
let source;
|
|
13404
13853
|
try {
|
|
13405
|
-
source = await
|
|
13854
|
+
source = await fs5.readFile(wranglerPath, "utf8");
|
|
13406
13855
|
} catch (error) {
|
|
13407
13856
|
if (error.code === "ENOENT") return;
|
|
13408
13857
|
throw error;
|
|
@@ -13410,7 +13859,7 @@ async function populateCloudflareProcessEnv(serverDir, fs4) {
|
|
|
13410
13859
|
const wrangler = JSON.parse(source);
|
|
13411
13860
|
const flags = resolveCloudflareProcessEnvFlags(wrangler);
|
|
13412
13861
|
if (!flags) return;
|
|
13413
|
-
await
|
|
13862
|
+
await fs5.writeFile(
|
|
13414
13863
|
wranglerPath,
|
|
13415
13864
|
JSON.stringify({ ...wrangler, compatibility_flags: flags }, null, 2)
|
|
13416
13865
|
);
|
|
@@ -13423,36 +13872,36 @@ function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
|
|
|
13423
13872
|
}))
|
|
13424
13873
|
);
|
|
13425
13874
|
}
|
|
13426
|
-
async function writeSSRBundleFiles(files, targetDir,
|
|
13427
|
-
await
|
|
13875
|
+
async function writeSSRBundleFiles(files, targetDir, fs5) {
|
|
13876
|
+
await fs5.rm(targetDir, { recursive: true, force: true });
|
|
13428
13877
|
await Promise.all(
|
|
13429
13878
|
files.map(async ({ fileName, contents }) => {
|
|
13430
|
-
const targetPath =
|
|
13431
|
-
await
|
|
13432
|
-
await
|
|
13879
|
+
const targetPath = path15.join(targetDir, fileName);
|
|
13880
|
+
await fs5.mkdir(path15.dirname(targetPath), { recursive: true });
|
|
13881
|
+
await fs5.writeFile(targetPath, contents);
|
|
13433
13882
|
})
|
|
13434
13883
|
);
|
|
13435
13884
|
}
|
|
13436
|
-
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions,
|
|
13437
|
-
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir,
|
|
13885
|
+
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs5) {
|
|
13886
|
+
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs5);
|
|
13438
13887
|
}
|
|
13439
|
-
async function installFarmCompileCacheLauncher(serverDir,
|
|
13440
|
-
const entryPath =
|
|
13441
|
-
const serverPath =
|
|
13442
|
-
const entry = await
|
|
13888
|
+
async function installFarmCompileCacheLauncher(serverDir, fs5) {
|
|
13889
|
+
const entryPath = path15.join(serverDir, "index.mjs");
|
|
13890
|
+
const serverPath = path15.join(serverDir, FARM_SERVER_MODULE_FILE);
|
|
13891
|
+
const entry = await fs5.readFile(entryPath, "utf8").catch((error) => {
|
|
13443
13892
|
if (error.code === "ENOENT") return null;
|
|
13444
13893
|
throw error;
|
|
13445
13894
|
});
|
|
13446
13895
|
if (entry === null) return false;
|
|
13447
13896
|
if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
|
|
13448
|
-
await
|
|
13449
|
-
await
|
|
13450
|
-
await
|
|
13897
|
+
await fs5.rename(entryPath, serverPath);
|
|
13898
|
+
await fs5.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
|
|
13899
|
+
await fs5.rm(path15.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
|
|
13451
13900
|
return true;
|
|
13452
13901
|
}
|
|
13453
|
-
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile,
|
|
13454
|
-
const packagePath =
|
|
13455
|
-
const packageJSON = await
|
|
13902
|
+
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs5) {
|
|
13903
|
+
const packagePath = path15.join(serverDir, "package.json");
|
|
13904
|
+
const packageJSON = await fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13456
13905
|
if (error.code === "ENOENT") return { type: "module" };
|
|
13457
13906
|
throw error;
|
|
13458
13907
|
});
|
|
@@ -13462,13 +13911,13 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
|
|
|
13462
13911
|
...existingImports,
|
|
13463
13912
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
13464
13913
|
};
|
|
13465
|
-
await
|
|
13466
|
-
await
|
|
13914
|
+
await fs5.mkdir(serverDir, { recursive: true });
|
|
13915
|
+
await fs5.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
|
|
13467
13916
|
`);
|
|
13468
13917
|
}
|
|
13469
|
-
async function moveVercelOutputPath(src, dest,
|
|
13918
|
+
async function moveVercelOutputPath(src, dest, fs5) {
|
|
13470
13919
|
try {
|
|
13471
|
-
await
|
|
13920
|
+
await fs5.rename(src, dest);
|
|
13472
13921
|
return;
|
|
13473
13922
|
} catch (error) {
|
|
13474
13923
|
const code = error?.code;
|
|
@@ -13476,38 +13925,38 @@ async function moveVercelOutputPath(src, dest, fs4) {
|
|
|
13476
13925
|
throw error;
|
|
13477
13926
|
}
|
|
13478
13927
|
}
|
|
13479
|
-
await
|
|
13480
|
-
await
|
|
13928
|
+
await fs5.cp(src, dest, { recursive: true, force: true });
|
|
13929
|
+
await fs5.rm(src, { recursive: true, force: true });
|
|
13481
13930
|
}
|
|
13482
|
-
async function postProcessVercelOutput(root, outputDir,
|
|
13483
|
-
const serverDir =
|
|
13484
|
-
const functionsDir =
|
|
13485
|
-
const nitroFuncDir =
|
|
13486
|
-
const staticDir =
|
|
13487
|
-
const publicDir =
|
|
13488
|
-
await
|
|
13489
|
-
const serverContents = await
|
|
13931
|
+
async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
|
|
13932
|
+
const serverDir = path15.join(outputDir, "server");
|
|
13933
|
+
const functionsDir = path15.join(outputDir, "functions");
|
|
13934
|
+
const nitroFuncDir = path15.join(functionsDir, "__nitro.func");
|
|
13935
|
+
const staticDir = path15.join(outputDir, "static");
|
|
13936
|
+
const publicDir = path15.join(outputDir, "public");
|
|
13937
|
+
await fs5.mkdir(nitroFuncDir, { recursive: true });
|
|
13938
|
+
const serverContents = await fs5.readdir(serverDir).catch((error) => {
|
|
13490
13939
|
if (error.code === "ENOENT") return [];
|
|
13491
13940
|
throw error;
|
|
13492
13941
|
});
|
|
13493
13942
|
for (const file of serverContents) {
|
|
13494
|
-
await moveVercelOutputPath(
|
|
13943
|
+
await moveVercelOutputPath(path15.join(serverDir, file), path15.join(nitroFuncDir, file), fs5);
|
|
13495
13944
|
}
|
|
13496
|
-
if (serverContents.length > 0) await
|
|
13945
|
+
if (serverContents.length > 0) await fs5.rm(serverDir, { recursive: true, force: true });
|
|
13497
13946
|
try {
|
|
13498
|
-
await moveVercelOutputPath(publicDir, staticDir,
|
|
13947
|
+
await moveVercelOutputPath(publicDir, staticDir, fs5);
|
|
13499
13948
|
} catch (error) {
|
|
13500
13949
|
if (error?.code !== "ENOENT") throw error;
|
|
13501
13950
|
}
|
|
13502
|
-
await copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
13503
|
-
await copyPrismaClientForVercel(root, nitroFuncDir,
|
|
13504
|
-
const configPath =
|
|
13505
|
-
const configContent = await
|
|
13951
|
+
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5);
|
|
13952
|
+
await copyPrismaClientForVercel(root, nitroFuncDir, fs5);
|
|
13953
|
+
const configPath = path15.join(outputDir, "config.json");
|
|
13954
|
+
const configContent = await fs5.readFile(configPath, "utf-8");
|
|
13506
13955
|
const vercelConfig = JSON.parse(configContent);
|
|
13507
13956
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
13508
13957
|
outputDir,
|
|
13509
13958
|
routeRuntimeManifest,
|
|
13510
|
-
|
|
13959
|
+
fs5,
|
|
13511
13960
|
config.basePath
|
|
13512
13961
|
);
|
|
13513
13962
|
const edgeMiddlewareRoutes = edgeMiddleware.middlewareRoutes.filter(
|
|
@@ -13521,7 +13970,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13521
13970
|
config,
|
|
13522
13971
|
routes: edgeMiddlewareRoutes,
|
|
13523
13972
|
guardedPages: edgeMiddleware.guardedPages,
|
|
13524
|
-
fs:
|
|
13973
|
+
fs: fs5
|
|
13525
13974
|
});
|
|
13526
13975
|
}
|
|
13527
13976
|
vercelConfig.routes = buildFarmVercelRoutes({
|
|
@@ -13535,30 +13984,30 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13535
13984
|
farmWorkflows.workflows
|
|
13536
13985
|
);
|
|
13537
13986
|
const vercelConfigWithCrons = applyFarmCronVercelCrons(vercelConfigWithWorkflowCrons, cronJobs);
|
|
13538
|
-
await
|
|
13987
|
+
await fs5.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
|
|
13539
13988
|
logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
|
|
13540
13989
|
}
|
|
13541
|
-
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
13990
|
+
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
|
|
13542
13991
|
if (!config.docs?.enabled) return;
|
|
13543
13992
|
const [mainRoot, ...extraRoots] = getFarmDocsRoots(config.docs);
|
|
13544
13993
|
await copyFarmDocsRootContent(
|
|
13545
13994
|
mainRoot,
|
|
13546
13995
|
root,
|
|
13547
13996
|
config.srcDir,
|
|
13548
|
-
|
|
13549
|
-
|
|
13997
|
+
path15.join(nitroFuncDir, "farm-docs-content"),
|
|
13998
|
+
fs5
|
|
13550
13999
|
);
|
|
13551
14000
|
for (const [index, docsRoot] of extraRoots.entries()) {
|
|
13552
14001
|
await copyFarmDocsRootContent(
|
|
13553
14002
|
docsRoot,
|
|
13554
14003
|
root,
|
|
13555
14004
|
config.srcDir,
|
|
13556
|
-
|
|
13557
|
-
|
|
14005
|
+
path15.join(nitroFuncDir, "farm-docs-roots", String(index)),
|
|
14006
|
+
fs5
|
|
13558
14007
|
);
|
|
13559
14008
|
}
|
|
13560
14009
|
}
|
|
13561
|
-
async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir,
|
|
14010
|
+
async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs5) {
|
|
13562
14011
|
const docsContentDir = resolveBuildDocsContentDir(docs, root, srcDir);
|
|
13563
14012
|
if (!docsContentDir) return;
|
|
13564
14013
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
@@ -13570,19 +14019,19 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
|
|
|
13570
14019
|
`${undatedPages} docs page(s) were last changed before this shallow clone's Git history, so they show no "Last updated" date. Build from a full clone (git fetch --unshallow) or set lastModified in the page's frontmatter.`
|
|
13571
14020
|
);
|
|
13572
14021
|
}
|
|
13573
|
-
await
|
|
13574
|
-
await
|
|
13575
|
-
await
|
|
14022
|
+
await fs5.rm(bundledContentDir, { recursive: true, force: true });
|
|
14023
|
+
await fs5.mkdir(path15.dirname(bundledContentDir), { recursive: true });
|
|
14024
|
+
await fs5.cp(docsContentDir, bundledContentDir, {
|
|
13576
14025
|
recursive: true,
|
|
13577
14026
|
force: true,
|
|
13578
14027
|
dereference: true
|
|
13579
14028
|
});
|
|
13580
|
-
await
|
|
13581
|
-
|
|
14029
|
+
await fs5.writeFile(
|
|
14030
|
+
path15.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
13582
14031
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
13583
14032
|
`
|
|
13584
14033
|
);
|
|
13585
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
14034
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path15.relative(root, docsContentDir)}`);
|
|
13586
14035
|
}
|
|
13587
14036
|
function resolveServerFunctionPlatform(preset) {
|
|
13588
14037
|
return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
|
|
@@ -13597,9 +14046,9 @@ function platformFieldAllows(field, value) {
|
|
|
13597
14046
|
const allowed = entries.filter((entry) => !entry.startsWith("!"));
|
|
13598
14047
|
return allowed.length === 0 || allowed.includes(value);
|
|
13599
14048
|
}
|
|
13600
|
-
async function stageSharpRuntime(config, root, distDir,
|
|
14049
|
+
async function stageSharpRuntime(config, root, distDir, fs5, preset) {
|
|
13601
14050
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
13602
|
-
const projectRequire = createRequire2(
|
|
14051
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
13603
14052
|
let sharpRequire = projectRequire;
|
|
13604
14053
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
13605
14054
|
try {
|
|
@@ -13609,10 +14058,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13609
14058
|
}
|
|
13610
14059
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
13611
14060
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
13612
|
-
const stageRoot =
|
|
13613
|
-
await
|
|
13614
|
-
const stageDir = await
|
|
13615
|
-
const targetNodeModules =
|
|
14061
|
+
const stageRoot = path15.join(root, distDir, "tmp");
|
|
14062
|
+
await fs5.mkdir(stageRoot, { recursive: true });
|
|
14063
|
+
const stageDir = await fs5.mkdtemp(path15.join(stageRoot, "sharp-runtime-"));
|
|
14064
|
+
const targetNodeModules = path15.join(stageDir, "node_modules");
|
|
13616
14065
|
function copyPackage(packageName, parentRequire) {
|
|
13617
14066
|
const activeCopy = packageCopies.get(packageName);
|
|
13618
14067
|
if (activeCopy) return activeCopy;
|
|
@@ -13623,19 +14072,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13623
14072
|
async function copyPackageOnce(packageName, parentRequire) {
|
|
13624
14073
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
13625
14074
|
if (!packageJsonPath) return;
|
|
13626
|
-
const packageJson = JSON.parse(await
|
|
14075
|
+
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
13627
14076
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
13628
|
-
const packageDir =
|
|
13629
|
-
const targetDir =
|
|
14077
|
+
const packageDir = path15.dirname(packageJsonPath);
|
|
14078
|
+
const targetDir = path15.join(targetNodeModules, ...packageName.split("/"));
|
|
13630
14079
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
13631
|
-
await
|
|
14080
|
+
await fs5.mkdir(path15.dirname(targetDir), { recursive: true });
|
|
13632
14081
|
const packageRequire = createRequire2(packageJsonPath);
|
|
13633
14082
|
const dependencies = {
|
|
13634
14083
|
...packageJson.dependencies,
|
|
13635
14084
|
...packageJson.optionalDependencies
|
|
13636
14085
|
};
|
|
13637
14086
|
await settleAllOrThrow([
|
|
13638
|
-
|
|
14087
|
+
fs5.cp(packageDir, targetDir, {
|
|
13639
14088
|
recursive: true,
|
|
13640
14089
|
force: true,
|
|
13641
14090
|
dereference: true,
|
|
@@ -13652,7 +14101,7 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13652
14101
|
throw new Error(`Farm image optimization requires sharp. ${SHARP_INSTALL_HINT}`);
|
|
13653
14102
|
}
|
|
13654
14103
|
} catch (error) {
|
|
13655
|
-
await
|
|
14104
|
+
await fs5.rm(stageDir, { recursive: true, force: true });
|
|
13656
14105
|
throw error;
|
|
13657
14106
|
}
|
|
13658
14107
|
return {
|
|
@@ -13662,19 +14111,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13662
14111
|
)
|
|
13663
14112
|
};
|
|
13664
14113
|
}
|
|
13665
|
-
async function installStagedSharpRuntime(staged, nitroFuncDir,
|
|
13666
|
-
const stagedNodeModules =
|
|
13667
|
-
const targetNodeModules =
|
|
14114
|
+
async function installStagedSharpRuntime(staged, nitroFuncDir, fs5) {
|
|
14115
|
+
const stagedNodeModules = path15.join(staged.stageDir, "node_modules");
|
|
14116
|
+
const targetNodeModules = path15.join(nitroFuncDir, "node_modules");
|
|
13668
14117
|
try {
|
|
13669
|
-
await mergeStagedDirectory(stagedNodeModules, targetNodeModules,
|
|
13670
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
14118
|
+
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs5);
|
|
14119
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
|
|
13671
14120
|
functionPackage.dependencies = {
|
|
13672
14121
|
...functionPackage.dependencies,
|
|
13673
14122
|
...staged.dependencies
|
|
13674
14123
|
};
|
|
13675
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14124
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13676
14125
|
} finally {
|
|
13677
|
-
await
|
|
14126
|
+
await fs5.rm(staged.stageDir, { recursive: true, force: true });
|
|
13678
14127
|
}
|
|
13679
14128
|
logger.info(
|
|
13680
14129
|
`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${Object.keys(staged.dependencies).length} packages)`
|
|
@@ -13687,15 +14136,15 @@ async function settleAllOrThrow(operations) {
|
|
|
13687
14136
|
);
|
|
13688
14137
|
if (failure) throw failure.reason;
|
|
13689
14138
|
}
|
|
13690
|
-
async function mergeStagedDirectory(sourceDir, targetDir,
|
|
13691
|
-
await
|
|
13692
|
-
const entries = await
|
|
14139
|
+
async function mergeStagedDirectory(sourceDir, targetDir, fs5) {
|
|
14140
|
+
await fs5.mkdir(targetDir, { recursive: true });
|
|
14141
|
+
const entries = await fs5.readdir(sourceDir, { withFileTypes: true });
|
|
13693
14142
|
await settleAllOrThrow(
|
|
13694
14143
|
entries.map(async (entry) => {
|
|
13695
|
-
const sourcePath =
|
|
13696
|
-
const targetPath =
|
|
14144
|
+
const sourcePath = path15.join(sourceDir, entry.name);
|
|
14145
|
+
const targetPath = path15.join(targetDir, entry.name);
|
|
13697
14146
|
try {
|
|
13698
|
-
await
|
|
14147
|
+
await fs5.rename(sourcePath, targetPath);
|
|
13699
14148
|
return;
|
|
13700
14149
|
} catch (error) {
|
|
13701
14150
|
const code = error.code;
|
|
@@ -13704,29 +14153,29 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
|
13704
14153
|
}
|
|
13705
14154
|
}
|
|
13706
14155
|
if (entry.isDirectory()) {
|
|
13707
|
-
await mergeStagedDirectory(sourcePath, targetPath,
|
|
13708
|
-
await
|
|
14156
|
+
await mergeStagedDirectory(sourcePath, targetPath, fs5);
|
|
14157
|
+
await fs5.rm(sourcePath, { recursive: true, force: true });
|
|
13709
14158
|
return;
|
|
13710
14159
|
}
|
|
13711
|
-
await
|
|
14160
|
+
await fs5.cp(sourcePath, targetPath, {
|
|
13712
14161
|
force: true,
|
|
13713
14162
|
dereference: true,
|
|
13714
14163
|
mode: fsConstants.COPYFILE_FICLONE
|
|
13715
14164
|
});
|
|
13716
|
-
await
|
|
14165
|
+
await fs5.rm(sourcePath, { force: true });
|
|
13717
14166
|
})
|
|
13718
14167
|
);
|
|
13719
14168
|
}
|
|
13720
14169
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
13721
14170
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
13722
14171
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
13723
|
-
const file = generated.modulePath ? toPosixPath(
|
|
14172
|
+
const file = generated.modulePath ? toPosixPath(path15.relative(root, generated.modulePath)) : "";
|
|
13724
14173
|
throw new Error(
|
|
13725
14174
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
13726
14175
|
);
|
|
13727
14176
|
}
|
|
13728
14177
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
13729
|
-
const projectRequire = createRequire2(
|
|
14178
|
+
const projectRequire = createRequire2(path15.join(root, "package.json"));
|
|
13730
14179
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
13731
14180
|
if (packageJsonPath) return packageJsonPath;
|
|
13732
14181
|
try {
|
|
@@ -13735,38 +14184,38 @@ function resolveMetadataImageRuntimePackageJson(root) {
|
|
|
13735
14184
|
return null;
|
|
13736
14185
|
}
|
|
13737
14186
|
}
|
|
13738
|
-
async function copyMetadataImageRuntime(root, nitroFuncDir,
|
|
14187
|
+
async function copyMetadataImageRuntime(root, nitroFuncDir, fs5) {
|
|
13739
14188
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
13740
14189
|
if (!packageJsonPath) return;
|
|
13741
|
-
const packageJson = JSON.parse(await
|
|
13742
|
-
const packageDir =
|
|
13743
|
-
const targetDir =
|
|
13744
|
-
await
|
|
13745
|
-
await
|
|
14190
|
+
const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
|
|
14191
|
+
const packageDir = path15.dirname(packageJsonPath);
|
|
14192
|
+
const targetDir = path15.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
14193
|
+
await fs5.mkdir(path15.dirname(targetDir), { recursive: true });
|
|
14194
|
+
await fs5.cp(packageDir, targetDir, {
|
|
13746
14195
|
recursive: true,
|
|
13747
14196
|
force: true,
|
|
13748
14197
|
dereference: true,
|
|
13749
14198
|
mode: fsConstants.COPYFILE_FICLONE
|
|
13750
14199
|
});
|
|
13751
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
14200
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
|
|
13752
14201
|
functionPackage.dependencies = {
|
|
13753
14202
|
...functionPackage.dependencies,
|
|
13754
14203
|
"@vercel/og": String(packageJson.version || "0.11.1")
|
|
13755
14204
|
};
|
|
13756
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14205
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13757
14206
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
13758
14207
|
}
|
|
13759
|
-
async function readNitroOutputPackage(outputDir,
|
|
13760
|
-
const packagePath =
|
|
13761
|
-
return
|
|
14208
|
+
async function readNitroOutputPackage(outputDir, fs5) {
|
|
14209
|
+
const packagePath = path15.join(outputDir, "package.json");
|
|
14210
|
+
return fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13762
14211
|
if (error.code === "ENOENT") return {};
|
|
13763
14212
|
throw error;
|
|
13764
14213
|
});
|
|
13765
14214
|
}
|
|
13766
|
-
async function writeNitroOutputPackage(outputDir, packageJson,
|
|
13767
|
-
await
|
|
13768
|
-
await
|
|
13769
|
-
|
|
14215
|
+
async function writeNitroOutputPackage(outputDir, packageJson, fs5) {
|
|
14216
|
+
await fs5.mkdir(outputDir, { recursive: true });
|
|
14217
|
+
await fs5.writeFile(
|
|
14218
|
+
path15.join(outputDir, "package.json"),
|
|
13770
14219
|
`${JSON.stringify(packageJson, null, 2)}
|
|
13771
14220
|
`
|
|
13772
14221
|
);
|
|
@@ -13782,70 +14231,70 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
13782
14231
|
}
|
|
13783
14232
|
}
|
|
13784
14233
|
try {
|
|
13785
|
-
let directory =
|
|
13786
|
-
while (directory !==
|
|
13787
|
-
const candidate =
|
|
13788
|
-
if (
|
|
14234
|
+
let directory = path15.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
14235
|
+
while (directory !== path15.dirname(directory)) {
|
|
14236
|
+
const candidate = path15.join(directory, "package.json");
|
|
14237
|
+
if (existsSync3(candidate)) {
|
|
13789
14238
|
try {
|
|
13790
14239
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
13791
14240
|
if (manifest.name === packageName) return candidate;
|
|
13792
14241
|
} catch {
|
|
13793
14242
|
}
|
|
13794
14243
|
}
|
|
13795
|
-
if (
|
|
13796
|
-
directory =
|
|
14244
|
+
if (path15.basename(directory) === "node_modules") break;
|
|
14245
|
+
directory = path15.dirname(directory);
|
|
13797
14246
|
}
|
|
13798
14247
|
} catch {
|
|
13799
14248
|
}
|
|
13800
14249
|
return null;
|
|
13801
14250
|
}
|
|
13802
|
-
async function resolveProjectInstalledPackageDir(root, packageName,
|
|
13803
|
-
let directory =
|
|
14251
|
+
async function resolveProjectInstalledPackageDir(root, packageName, fs5) {
|
|
14252
|
+
let directory = path15.resolve(root);
|
|
13804
14253
|
while (true) {
|
|
13805
|
-
const candidate =
|
|
14254
|
+
const candidate = path15.join(directory, "node_modules", ...packageName.split("/"));
|
|
13806
14255
|
try {
|
|
13807
|
-
const packageDir = await
|
|
13808
|
-
if ((await
|
|
14256
|
+
const packageDir = await fs5.realpath(candidate);
|
|
14257
|
+
if ((await fs5.stat(path15.join(packageDir, "package.json"))).isFile()) return packageDir;
|
|
13809
14258
|
} catch {
|
|
13810
14259
|
}
|
|
13811
|
-
const parent =
|
|
14260
|
+
const parent = path15.dirname(directory);
|
|
13812
14261
|
if (parent === directory) return null;
|
|
13813
14262
|
directory = parent;
|
|
13814
14263
|
}
|
|
13815
14264
|
}
|
|
13816
|
-
async function copyPrismaClientForVercel(root, nitroFuncDir,
|
|
13817
|
-
const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client",
|
|
14265
|
+
async function copyPrismaClientForVercel(root, nitroFuncDir, fs5) {
|
|
14266
|
+
const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs5);
|
|
13818
14267
|
if (!prismaClientDir) return;
|
|
13819
|
-
const generatedClientDir =
|
|
14268
|
+
const generatedClientDir = path15.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
13820
14269
|
try {
|
|
13821
|
-
await
|
|
14270
|
+
await fs5.access(generatedClientDir);
|
|
13822
14271
|
} catch {
|
|
13823
14272
|
return;
|
|
13824
14273
|
}
|
|
13825
|
-
const targetNodeModules =
|
|
13826
|
-
const targetPrismaScopeDir =
|
|
13827
|
-
const targetGeneratedDir =
|
|
13828
|
-
const targetClientDir =
|
|
13829
|
-
await
|
|
13830
|
-
await
|
|
14274
|
+
const targetNodeModules = path15.join(nitroFuncDir, "node_modules");
|
|
14275
|
+
const targetPrismaScopeDir = path15.join(targetNodeModules, "@prisma");
|
|
14276
|
+
const targetGeneratedDir = path15.join(targetNodeModules, ".prisma", "client");
|
|
14277
|
+
const targetClientDir = path15.join(targetPrismaScopeDir, "client");
|
|
14278
|
+
await fs5.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
14279
|
+
await fs5.cp(prismaClientDir, targetClientDir, {
|
|
13831
14280
|
recursive: true,
|
|
13832
14281
|
force: true
|
|
13833
14282
|
});
|
|
13834
|
-
await
|
|
14283
|
+
await fs5.cp(generatedClientDir, targetGeneratedDir, {
|
|
13835
14284
|
recursive: true,
|
|
13836
14285
|
force: true
|
|
13837
14286
|
});
|
|
13838
|
-
const clientPackagePath =
|
|
14287
|
+
const clientPackagePath = path15.join(prismaClientDir, "package.json");
|
|
13839
14288
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
13840
|
-
readNitroOutputPackage(nitroFuncDir,
|
|
13841
|
-
|
|
14289
|
+
readNitroOutputPackage(nitroFuncDir, fs5),
|
|
14290
|
+
fs5.readFile(clientPackagePath, "utf-8")
|
|
13842
14291
|
]);
|
|
13843
14292
|
const clientPackage = JSON.parse(clientPackageContent);
|
|
13844
14293
|
functionPackage.dependencies = {
|
|
13845
14294
|
...functionPackage.dependencies,
|
|
13846
14295
|
"@prisma/client": clientPackage.version
|
|
13847
14296
|
};
|
|
13848
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
14297
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
|
|
13849
14298
|
}
|
|
13850
14299
|
function islandsActionKeyCode() {
|
|
13851
14300
|
const key = randomBytes(32).toString("base64url");
|
|
@@ -13975,6 +14424,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
13975
14424
|
rendererBuild.signal
|
|
13976
14425
|
);
|
|
13977
14426
|
const farmApp = createFarmApp(config, projectModuleServer);
|
|
14427
|
+
if (options.universal !== false) farmApp.getRouteManager().keepBuildSourceSnapshot();
|
|
13978
14428
|
await farmApp.initialize();
|
|
13979
14429
|
const routeManager = farmApp.getRouteManager();
|
|
13980
14430
|
const serverRenderer = farmApp.getServerRenderer();
|
|
@@ -14021,9 +14471,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
14021
14471
|
} else {
|
|
14022
14472
|
const { build: legacyViteBuild } = await import("vite");
|
|
14023
14473
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
14024
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
14474
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path16.join(root, distDir, "client"));
|
|
14025
14475
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
14026
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
14476
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path16.join(root, distDir, "server"));
|
|
14027
14477
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
14028
14478
|
await buildNitro(
|
|
14029
14479
|
config,
|
|
@@ -14125,8 +14575,8 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
14125
14575
|
root,
|
|
14126
14576
|
// Vite keys its pre-bundled dependencies on the config, mode included, so this server and
|
|
14127
14577
|
// `farm dev` sharing one cache would each rebuild it after the other ran.
|
|
14128
|
-
cacheDir:
|
|
14129
|
-
|
|
14578
|
+
cacheDir: path16.join(
|
|
14579
|
+
path16.resolve(root, viteConfig.cacheDir ?? path16.join("node_modules", ".vite")),
|
|
14130
14580
|
"farm-build"
|
|
14131
14581
|
),
|
|
14132
14582
|
configFile: false,
|
|
@@ -14159,7 +14609,12 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
14159
14609
|
});
|
|
14160
14610
|
}
|
|
14161
14611
|
async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
14162
|
-
const {
|
|
14612
|
+
const {
|
|
14613
|
+
farmI18nClientBridgePlugin,
|
|
14614
|
+
farmIslandContainersPlugin,
|
|
14615
|
+
farmPlugin,
|
|
14616
|
+
farmServerOnlyEntriesPlugin
|
|
14617
|
+
} = await import("./vite.mjs");
|
|
14163
14618
|
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
14164
14619
|
const pluginManager = new PluginManager2({
|
|
14165
14620
|
config,
|
|
@@ -14179,6 +14634,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14179
14634
|
plugins: [
|
|
14180
14635
|
farmI18nClientBridgePlugin(),
|
|
14181
14636
|
farmServerOnlyEntriesPlugin(),
|
|
14637
|
+
farmIslandContainersPlugin(config),
|
|
14182
14638
|
farmPlugin(config, pluginManager),
|
|
14183
14639
|
farmEnvironmentFunctionsPlugin(config)
|
|
14184
14640
|
],
|
|
@@ -14186,7 +14642,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14186
14642
|
});
|
|
14187
14643
|
}
|
|
14188
14644
|
async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
14189
|
-
const { farmI18nClientBridgePlugin, farmPlugin } = await import("./vite.mjs");
|
|
14645
|
+
const { farmI18nClientBridgePlugin, farmIslandContainersPlugin, farmPlugin } = await import("./vite.mjs");
|
|
14190
14646
|
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
14191
14647
|
const pluginManager = new PluginManager2({
|
|
14192
14648
|
config,
|
|
@@ -14212,6 +14668,7 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14212
14668
|
},
|
|
14213
14669
|
plugins: [
|
|
14214
14670
|
farmI18nClientBridgePlugin(),
|
|
14671
|
+
farmIslandContainersPlugin(config),
|
|
14215
14672
|
farmPlugin(config, pluginManager),
|
|
14216
14673
|
farmEnvironmentFunctionsPlugin(config)
|
|
14217
14674
|
],
|
|
@@ -14219,16 +14676,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
14219
14676
|
});
|
|
14220
14677
|
}
|
|
14221
14678
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
14222
|
-
const appDir =
|
|
14679
|
+
const appDir = path16.join(root, srcDir, "app");
|
|
14223
14680
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
14224
|
-
const candidate =
|
|
14225
|
-
if (
|
|
14681
|
+
const candidate = path16.join(appDir, `page${extension}`);
|
|
14682
|
+
if (existsSync4(candidate)) return candidate;
|
|
14226
14683
|
}
|
|
14227
|
-
return
|
|
14684
|
+
return path16.join(appDir, "page.tsx");
|
|
14228
14685
|
}
|
|
14229
14686
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
14230
14687
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
14231
|
-
import("./nitro-
|
|
14688
|
+
import("./nitro-XTQ2HKDL.mjs"),
|
|
14232
14689
|
import("nitro/builder")
|
|
14233
14690
|
]);
|
|
14234
14691
|
let nitroConfig = await createNitroConfig(
|
|
@@ -14242,23 +14699,23 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14242
14699
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
14243
14700
|
}
|
|
14244
14701
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
14245
|
-
const serverOutputDir =
|
|
14246
|
-
const publicOutputDir =
|
|
14702
|
+
const serverOutputDir = path16.join(outputDir, "server");
|
|
14703
|
+
const publicOutputDir = path16.join(outputDir, "public");
|
|
14247
14704
|
const { mkdir, cp } = await import("fs/promises");
|
|
14248
14705
|
await mkdir(serverOutputDir, { recursive: true });
|
|
14249
14706
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14250
|
-
const clientDir =
|
|
14707
|
+
const clientDir = path16.join(root, distDir, "client");
|
|
14251
14708
|
try {
|
|
14252
14709
|
await mkdir(publicOutputDir, { recursive: true });
|
|
14253
14710
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
14254
14711
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
14255
|
-
const manifestPath =
|
|
14256
|
-
const assetsDir =
|
|
14712
|
+
const manifestPath = path16.join(publicOutputDir, "farm-client-manifest.json");
|
|
14713
|
+
const assetsDir = path16.join(publicOutputDir, "assets");
|
|
14257
14714
|
const manifestExists = await import("fs/promises").then(
|
|
14258
|
-
(
|
|
14715
|
+
(fs5) => fs5.access(manifestPath).then(() => true).catch(() => false)
|
|
14259
14716
|
);
|
|
14260
14717
|
const assetsExist = await import("fs/promises").then(
|
|
14261
|
-
(
|
|
14718
|
+
(fs5) => fs5.access(assetsDir).then(() => true).catch(() => false)
|
|
14262
14719
|
);
|
|
14263
14720
|
if (manifestExists && assetsExist) {
|
|
14264
14721
|
logger.info("\u2705 Verified client assets are present");
|
|
@@ -14269,8 +14726,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14269
14726
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
14270
14727
|
throw error;
|
|
14271
14728
|
}
|
|
14272
|
-
const serverDir =
|
|
14273
|
-
const nitroServerDir =
|
|
14729
|
+
const serverDir = path16.join(root, distDir, "server");
|
|
14730
|
+
const nitroServerDir = path16.join(root, distDir, ".nitro", "server", "farm");
|
|
14274
14731
|
try {
|
|
14275
14732
|
await mkdir(nitroServerDir, { recursive: true });
|
|
14276
14733
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -14279,7 +14736,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14279
14736
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
14280
14737
|
}
|
|
14281
14738
|
const nitro = await createNitro(nitroConfig);
|
|
14282
|
-
const registryPath =
|
|
14739
|
+
const registryPath = path16.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
14283
14740
|
try {
|
|
14284
14741
|
const { farmRegistry } = await import(
|
|
14285
14742
|
/* @vite-ignore */
|
|
@@ -14296,7 +14753,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14296
14753
|
}
|
|
14297
14754
|
farmRegistry.routePaths = routePaths;
|
|
14298
14755
|
try {
|
|
14299
|
-
const clientManifestPath =
|
|
14756
|
+
const clientManifestPath = path16.join(root, distDir, "client", "farm-client-manifest.json");
|
|
14300
14757
|
const { readFile } = await import("fs/promises");
|
|
14301
14758
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
14302
14759
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|