@farm.js/core 0.1.39 → 0.1.40
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-BhneNPb4.d.mts → agent-mcp-DRlXq3lM.d.ts} +1 -1
- package/dist/{agent-mcp-HcTYQmNX.d.ts → agent-mcp-XNF4JqHw.d.mts} +1 -1
- package/dist/{agent-mcp-handler-OLRMZONF.mjs → agent-mcp-handler-HVV5LNXF.mjs} +6 -6
- package/dist/{agent-mcp-handler-MRGP3WJ3.cjs → agent-mcp-handler-YKG7KVCY.cjs} +7 -7
- package/dist/agent-runtime.cjs +10 -6
- package/dist/agent-runtime.d.mts +5 -7
- package/dist/agent-runtime.d.ts +5 -7
- package/dist/agent-runtime.mjs +9 -5
- package/dist/api/client.cjs +3 -3
- package/dist/api/client.d.mts +3 -3
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.mjs +2 -2
- package/dist/api/route-manager.cjs +15 -13
- package/dist/api/route-manager.d.mts +7 -9
- package/dist/api/route-manager.d.ts +7 -9
- package/dist/api/route-manager.mjs +14 -12
- package/dist/api/runtime.cjs +12 -10
- package/dist/api/runtime.d.mts +6 -8
- package/dist/api/runtime.d.ts +6 -8
- package/dist/api/runtime.mjs +11 -9
- package/dist/{api-client-CyFtZFJ4.d.ts → api-client-BJv9mTbO.d.ts} +2 -2
- package/dist/{api-client-BjMmY8OD.d.mts → api-client-Dk9QOLwr.d.mts} +2 -2
- package/dist/api.cjs +17 -15
- package/dist/api.d.mts +9 -11
- package/dist/api.d.ts +9 -11
- package/dist/api.mjs +16 -14
- package/dist/{app-CMkoghtp.d.ts → app-CDJHPqZn.d.ts} +11 -4
- package/dist/{app-DVzmmbNO.d.mts → app-CWjCklhF.d.mts} +11 -4
- package/dist/app-markdown.cjs +7 -6
- package/dist/app-markdown.d.mts +6 -8
- package/dist/app-markdown.d.ts +6 -8
- package/dist/app-markdown.mjs +6 -5
- package/dist/cache.cjs +6 -3
- package/dist/cache.d.mts +23 -2
- package/dist/cache.d.ts +23 -2
- package/dist/cache.mjs +5 -2
- package/dist/{chunk-3UEVPCGW.mjs → chunk-2DMWQWNJ.mjs} +6 -1
- package/dist/{chunk-ZXH4TS3F.cjs → chunk-2JG2LJDI.cjs} +3 -64
- package/dist/{chunk-QTXBII4Z.cjs → chunk-3TB5QGUW.cjs} +5 -5
- package/dist/chunk-45QJHGZM.cjs +1063 -0
- package/dist/{chunk-QYMZOOC5.mjs → chunk-45UZKX2J.mjs} +12 -44
- package/dist/{chunk-FUCSUGDM.cjs → chunk-4A3YUB4D.cjs} +3 -3
- package/dist/{chunk-FUZEBRP3.mjs → chunk-4GP3XZ4Z.mjs} +5 -3
- package/dist/chunk-4TLUFAIP.cjs +92 -0
- package/dist/chunk-4U5XZDLG.cjs +80 -0
- package/dist/{chunk-VXEEATVD.cjs → chunk-4XO5GSD6.cjs} +2 -2
- package/dist/{chunk-P664ZVTV.mjs → chunk-4ZZNPK25.mjs} +2 -2
- package/dist/{chunk-YFYUYWL7.cjs → chunk-54QWHSNR.cjs} +697 -422
- package/dist/{chunk-W36M2BQ4.mjs → chunk-5E65AL7P.mjs} +3 -3
- package/dist/{chunk-3LOLJTFV.cjs → chunk-5JEC43MQ.cjs} +11 -11
- package/dist/{chunk-INL3THCU.mjs → chunk-5LL6TKII.mjs} +1 -1
- package/dist/{chunk-KIIMAWOJ.cjs → chunk-5NAVKJCZ.cjs} +35 -105
- package/dist/{chunk-PGZDEPTM.cjs → chunk-5XS5NCVM.cjs} +10 -10
- package/dist/{chunk-HXRYZWTA.mjs → chunk-62DY5GKS.mjs} +3 -3
- package/dist/{chunk-LSKZMJMP.cjs → chunk-64SBBZDU.cjs} +38 -1
- package/dist/chunk-6BWKJ6QS.cjs +43 -0
- package/dist/{chunk-JSROZYYO.cjs → chunk-6D24SDKO.cjs} +1 -20
- package/dist/{chunk-EIPC3FDA.cjs → chunk-6ILGLCXF.cjs} +9 -5
- package/dist/chunk-6QOLZITB.cjs +22 -0
- package/dist/{chunk-RW63BOV7.cjs → chunk-7FHZ3E6D.cjs} +2 -2
- package/dist/chunk-7GNWGLWB.mjs +14 -0
- package/dist/{chunk-34UCJRQO.cjs → chunk-7RNAKBWF.cjs} +2 -2
- package/dist/{chunk-MSSFIQGM.mjs → chunk-7VAJSSPG.mjs} +41 -10
- package/dist/{chunk-PVZE2JGJ.mjs → chunk-ACLPN56I.mjs} +43 -25
- package/dist/{chunk-JCYYXBAJ.cjs → chunk-AGR7F3LA.cjs} +3 -3
- package/dist/{chunk-UPJLHLJU.cjs → chunk-ALPWLT27.cjs} +4 -4
- package/dist/{chunk-ATSDUUFK.mjs → chunk-AX7S67YV.mjs} +33 -40
- package/dist/{chunk-CUM5NYL5.mjs → chunk-AXB5P7BK.mjs} +1 -1
- package/dist/{chunk-2ZYGC6SS.cjs → chunk-B6IMBBOS.cjs} +3 -3
- package/dist/{chunk-472NCAZ7.cjs → chunk-B77AUCBV.cjs} +3 -3
- package/dist/{chunk-H5CLOUZS.cjs → chunk-BMOBTMDR.cjs} +5 -5
- package/dist/{chunk-CQMVIOYP.mjs → chunk-BPGO2IEP.mjs} +7 -7
- package/dist/{chunk-E2ROOWQC.cjs → chunk-BPOTSHDO.cjs} +24 -87
- package/dist/chunk-BRYPZIMB.mjs +6 -0
- package/dist/{chunk-WFRT7JPX.mjs → chunk-BYQVROIP.mjs} +2 -2
- package/dist/{chunk-HALDNTIV.mjs → chunk-BYR3RQPB.mjs} +10 -73
- package/dist/{chunk-IWZKTWHZ.cjs → chunk-CA62IQY3.cjs} +7 -2
- package/dist/chunk-CALY6QG6.mjs +963 -0
- package/dist/{chunk-WC5UV2HQ.cjs → chunk-CBXBGM72.cjs} +2 -2
- package/dist/{chunk-WW46B6HA.cjs → chunk-CGR525MJ.cjs} +84 -45
- package/dist/{chunk-6V4TDWEC.cjs → chunk-CGVPXIRN.cjs} +18 -1
- package/dist/{chunk-677THUVP.mjs → chunk-CKFK3Z2V.mjs} +1 -1
- package/dist/chunk-CZS6OACQ.mjs +63 -0
- package/dist/{chunk-SGBJ247Q.cjs → chunk-D4ROBNTK.cjs} +2 -2
- package/dist/{chunk-WEW2JVA4.cjs → chunk-D5IHNDHI.cjs} +6 -6
- package/dist/{chunk-ULASELLA.cjs → chunk-DATEWH3W.cjs} +13 -1
- package/dist/{chunk-QUCXCDE2.cjs → chunk-DKU6NXRK.cjs} +1 -1
- package/dist/{chunk-NBBEQLOK.cjs → chunk-E55H6UKH.cjs} +9 -9
- package/dist/{chunk-AS2VPMEE.cjs → chunk-EGCT3AHF.cjs} +1440 -8172
- package/dist/{chunk-SDOTRX3V.cjs → chunk-EORXKFLR.cjs} +7 -7
- package/dist/{chunk-HD5CF3OE.mjs → chunk-ETPEZLS3.mjs} +2 -2
- package/dist/{chunk-RVXFINNS.cjs → chunk-EW4MEVLE.cjs} +30 -30
- package/dist/{chunk-HYTZYOW2.mjs → chunk-FCOLU5P6.mjs} +1172 -7904
- package/dist/chunk-FGH3ZXTP.mjs +1063 -0
- package/dist/{chunk-HRETEZ2Z.cjs → chunk-FLZ4H25A.cjs} +37 -35
- package/dist/chunk-FVPXT2JR.cjs +63 -0
- package/dist/{chunk-D2ULAULS.cjs → chunk-FXFKIJDA.cjs} +9 -7
- package/dist/chunk-GC3EM6H4.mjs +80 -0
- package/dist/chunk-GKQL726H.cjs +6096 -0
- package/dist/{chunk-5PWXMJOH.cjs → chunk-GNVEJUT5.cjs} +36 -36
- package/dist/{chunk-E3UK5IIB.cjs → chunk-GS3WR5HX.cjs} +5 -3
- package/dist/{chunk-QFW2IH5E.mjs → chunk-GZTUT75U.mjs} +5 -2
- package/dist/chunk-H3EGVQE5.mjs +22 -0
- package/dist/{chunk-LMPAPBUA.cjs → chunk-H44XGLFU.cjs} +36 -68
- package/dist/{chunk-SOP2EAA6.mjs → chunk-H56MQYEG.mjs} +1 -1
- package/dist/chunk-HANGSYMB.mjs +67 -0
- package/dist/{chunk-5BWWFHR2.mjs → chunk-HBEBV7OZ.mjs} +3 -3
- package/dist/{chunk-RSOJ7DRT.mjs → chunk-HCSVR4YZ.mjs} +1 -58
- package/dist/{chunk-P3PLW4FR.mjs → chunk-HKFBMHCD.mjs} +4 -4
- package/dist/{chunk-MLY2RP5R.mjs → chunk-I63UCMXW.mjs} +6 -2
- package/dist/{chunk-TO4GJ56K.cjs → chunk-I64GEPOB.cjs} +58 -18
- package/dist/{chunk-VNGH5MLF.mjs → chunk-I6UVKUYK.mjs} +1 -1
- package/dist/{chunk-EPYU2EBL.mjs → chunk-IF4NU2NG.mjs} +1 -1
- package/dist/{chunk-IVLZZZEI.mjs → chunk-IM7DY3ED.mjs} +1 -1
- package/dist/{chunk-YKZRDB5Z.mjs → chunk-IMQO6ZUU.mjs} +2 -2
- package/dist/{chunk-F5QO4FNE.mjs → chunk-INQ64HTJ.mjs} +43 -11
- package/dist/{chunk-BXDJXFQG.cjs → chunk-IRYK4Z5M.cjs} +4 -4
- package/dist/{chunk-UWPLULNK.mjs → chunk-JGHCKIRI.mjs} +84 -24
- package/dist/{chunk-BFJTHYTN.mjs → chunk-JIYYX7WU.mjs} +10 -8
- package/dist/{chunk-6MVFL3R5.cjs → chunk-JR4QCLJY.cjs} +1 -58
- package/dist/{chunk-Q2KB32T4.mjs → chunk-JXB6DVCO.mjs} +5 -5
- package/dist/{chunk-CGBDNNSM.cjs → chunk-KEXK442I.cjs} +44 -12
- package/dist/{chunk-5D2JIPLH.cjs → chunk-KK22JPQM.cjs} +10 -10
- package/dist/{chunk-EA5K5BKU.mjs → chunk-KNHBTJP6.mjs} +18 -1
- package/dist/{chunk-MVL2RAJW.mjs → chunk-KYN5ODF6.mjs} +1 -1
- package/dist/{chunk-B5J2YVG7.cjs → chunk-LDPKAYVS.cjs} +2 -2
- package/dist/chunk-LFHCG2DU.mjs +43 -0
- package/dist/{chunk-FZ6YYU2W.mjs → chunk-MGMF4VP7.mjs} +38 -1
- package/dist/{chunk-KTSUBU2E.mjs → chunk-MNUSIXGS.mjs} +2 -2
- package/dist/{chunk-MYIZXDZA.mjs → chunk-MOSYH4CY.mjs} +1 -1
- package/dist/{chunk-4ZFL5GFN.cjs → chunk-OILHPMFX.cjs} +86 -26
- package/dist/{chunk-AJQTP4OO.mjs → chunk-OJ7JP7RJ.mjs} +1 -1
- package/dist/{chunk-VWBHM3F6.mjs → chunk-OLQ73ZO5.mjs} +1 -1
- package/dist/{chunk-5OKBARDN.cjs → chunk-OZN4XL6L.cjs} +10 -10
- package/dist/{chunk-T5OJPTVN.cjs → chunk-P4TYB4SF.cjs} +2 -2
- package/dist/chunk-P7XDC7UJ.mjs +92 -0
- package/dist/{chunk-5ULKUBIA.cjs → chunk-PGW7HZE2.cjs} +6 -6
- package/dist/{chunk-SHLXACIO.cjs → chunk-PJ42JESY.cjs} +1 -9
- package/dist/{chunk-U6QLDL3G.mjs → chunk-PNCM5MFD.mjs} +1 -1
- package/dist/{chunk-OAHTRMIC.mjs → chunk-PYQ3ZG4Z.mjs} +11 -11
- package/dist/{chunk-KMTGADN3.mjs → chunk-QCVIRVHE.mjs} +1 -9
- package/dist/{chunk-RWFLWR5J.cjs → chunk-QJM7A4CR.cjs} +17 -15
- package/dist/{chunk-BWIQR4DH.cjs → chunk-RHGK2JEN.cjs} +56 -63
- package/dist/{chunk-QV4VE2OW.mjs → chunk-S6ENKNNG.mjs} +5 -3
- package/dist/{chunk-HRSAQ23K.cjs → chunk-SHFXCE5A.cjs} +4 -4
- package/dist/{chunk-EKN7NSZO.cjs → chunk-SZLNU3GJ.cjs} +8 -5
- package/dist/{chunk-WLL43JMO.mjs → chunk-T36UJS3X.mjs} +7 -5
- package/dist/{chunk-CNNOLE4O.mjs → chunk-T4II4MMW.mjs} +1 -1
- package/dist/{chunk-GKBWWRBG.mjs → chunk-T6DLMX5V.mjs} +11 -11
- package/dist/{chunk-CIOT4HGT.cjs → chunk-TAKG7ZCD.cjs} +14 -14
- package/dist/{chunk-SKVTP5PR.mjs → chunk-TFX4RTH2.mjs} +1 -62
- package/dist/chunk-TI7UANHI.cjs +77 -0
- package/dist/{chunk-6BK3K2GB.mjs → chunk-UIDWEU7M.mjs} +83 -44
- package/dist/{chunk-EGCTIS5F.mjs → chunk-UM3ZV5EP.mjs} +1 -1
- package/dist/{chunk-YWN746US.cjs → chunk-UMQAK3KP.cjs} +85 -54
- package/dist/chunk-UNJZGVPU.cjs +6 -0
- package/dist/{chunk-XKG2BLFN.cjs → chunk-UXMIFB44.cjs} +18 -35
- package/dist/{chunk-DMEPTZTI.mjs → chunk-VBN3UAPQ.mjs} +47 -7
- package/dist/chunk-VDRM36QB.cjs +963 -0
- package/dist/{chunk-RG4A6LB2.cjs → chunk-VNPXKF3G.cjs} +7 -7
- package/dist/chunk-VQDBNVOO.cjs +14 -0
- package/dist/chunk-VQGKD7RV.mjs +25 -0
- package/dist/{chunk-6HB6V3R7.mjs → chunk-WCWV25PG.mjs} +10 -27
- package/dist/{chunk-ZMSZZXOR.mjs → chunk-WDMIW6Q6.mjs} +0 -19
- package/dist/{chunk-4WVJLURN.mjs → chunk-WMHG64DA.mjs} +1 -1
- package/dist/{chunk-A657YSP4.cjs → chunk-WSOBCAYO.cjs} +37 -35
- package/dist/{chunk-ARC7I3O2.mjs → chunk-WW374SGU.mjs} +1 -1
- package/dist/{chunk-J63ZH5OQ.cjs → chunk-X3GMHKO3.cjs} +2 -2
- package/dist/{chunk-VT4WFRHA.mjs → chunk-XJAEZCT6.mjs} +1 -1
- package/dist/{chunk-ZUPXLIGB.mjs → chunk-XKIUHXHW.mjs} +618 -343
- package/dist/{chunk-6XWDE2P2.cjs → chunk-XVIEGKTT.cjs} +30 -5
- package/dist/{chunk-QG775BRV.cjs → chunk-Y2GNNXGV.cjs} +72 -54
- package/dist/{chunk-75HN5IZ3.mjs → chunk-Y4QVEU67.mjs} +21 -19
- package/dist/chunk-Y5RG6B7S.mjs +77 -0
- package/dist/{chunk-QRKIMN7T.mjs → chunk-Y6LRPO2K.mjs} +13 -1
- package/dist/{chunk-BZHXGVMA.mjs → chunk-YJBWB6GF.mjs} +5 -3
- package/dist/{chunk-WXJLNP33.cjs → chunk-YR2P74F7.cjs} +9 -7
- package/dist/chunk-YZAKIXRL.cjs +67 -0
- package/dist/chunk-ZKVJYQPO.mjs +6095 -0
- package/dist/{chunk-POSPE3IO.mjs → chunk-ZOABCQGT.mjs} +27 -2
- package/dist/chunk-ZQRCSUSB.cjs +25 -0
- package/dist/{chunk-ZMMBIVQM.mjs → chunk-ZZGQD7A4.mjs} +16 -86
- package/dist/{client-plugins-CsCuCLBz.d.mts → client-plugins-B_5QbNrp.d.mts} +2544 -2664
- package/dist/{client-plugins-D0ke-Hc8.d.ts → client-plugins-DgSfIWIF.d.ts} +2544 -2664
- package/dist/client-plugins.d.mts +5 -7
- package/dist/client-plugins.d.ts +5 -7
- package/dist/client.cjs +5 -5
- package/dist/client.d.mts +11 -12
- package/dist/client.d.ts +11 -12
- package/dist/client.mjs +4 -4
- package/dist/config.d.mts +5 -7
- package/dist/config.d.ts +5 -7
- package/dist/{devtools-LW4QQ5J3.cjs → devtools-ANJ7JAPQ.cjs} +21 -18
- package/dist/{devtools-5AFIPVUJ.mjs → devtools-VEQQDVHE.mjs} +20 -17
- package/dist/docs.cjs +23 -20
- package/dist/docs.d.mts +6 -8
- package/dist/docs.d.ts +6 -8
- package/dist/docs.mjs +22 -19
- package/dist/{endpoint-CA-TNX60.d.ts → endpoint-BOE0IAaG.d.ts} +6 -3
- package/dist/{endpoint-CCHFqyTE.d.mts → endpoint-DGZRZHux.d.mts} +6 -3
- package/dist/environment/vite.cjs +6 -2
- package/dist/environment/vite.d.mts +11 -2
- package/dist/environment/vite.d.ts +11 -2
- package/dist/environment/vite.mjs +5 -1
- package/dist/headers.cjs +4 -4
- package/dist/headers.mjs +3 -3
- package/dist/image/server.cjs +7 -3
- package/dist/image/server.d.mts +9 -1
- package/dist/image/server.d.ts +9 -1
- package/dist/image/server.mjs +6 -2
- package/dist/image/sharp.cjs +12 -10
- package/dist/image/sharp.mjs +4 -2
- package/dist/index.cjs +87 -67
- package/dist/index.d.mts +27 -24
- package/dist/index.d.ts +27 -24
- package/dist/index.mjs +100 -80
- package/dist/{integration-api-BPJo5oXb.d.ts → integration-api-BuPHMeKz.d.ts} +2 -2
- package/dist/{integration-api-0y4FXJpC.d.mts → integration-api-DWyMmvrR.d.mts} +2 -2
- package/dist/integration-orm-P2II2EBK.cjs +14 -0
- package/dist/{integration-orm-KV5B3BGZ.mjs → integration-orm-RBKCIQYZ.mjs} +4 -3
- package/dist/integrations.cjs +7 -5
- package/dist/integrations.d.mts +7 -9
- package/dist/integrations.d.ts +7 -9
- package/dist/integrations.mjs +6 -4
- package/dist/internal/app-markdown-runtime.cjs +6 -5
- package/dist/internal/app-markdown-runtime.d.mts +6 -8
- package/dist/internal/app-markdown-runtime.d.ts +6 -8
- package/dist/internal/app-markdown-runtime.mjs +5 -4
- package/dist/internal/build-runtime.cjs +56 -55
- package/dist/internal/build-runtime.d.mts +7 -9
- package/dist/internal/build-runtime.d.ts +7 -9
- package/dist/internal/build-runtime.mjs +55 -54
- package/dist/internal/cli-runtime.cjs +36 -30
- package/dist/internal/cli-runtime.mjs +36 -30
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +5 -7
- package/dist/internal/compression-runtime.d.ts +5 -7
- package/dist/internal/config-runtime.cjs +21 -18
- package/dist/internal/config-runtime.d.mts +6 -8
- package/dist/internal/config-runtime.d.ts +6 -8
- package/dist/internal/config-runtime.mjs +20 -17
- package/dist/internal/docs-precompiled-runtime.cjs +3 -3
- package/dist/internal/docs-precompiled-runtime.mjs +2 -2
- package/dist/internal/infra-analytics-runtime.cjs +7 -7
- package/dist/internal/infra-analytics-runtime.mjs +5 -5
- package/dist/internal/metadata-image-runtime.cjs +4 -3
- package/dist/internal/metadata-image-runtime.mjs +3 -2
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-node-env.cjs +2 -2
- package/dist/internal/production-node-env.mjs +1 -1
- package/dist/internal/production-runtime.cjs +44 -27
- package/dist/internal/production-runtime.d.mts +25 -14
- package/dist/internal/production-runtime.d.ts +25 -14
- package/dist/internal/production-runtime.mjs +47 -30
- package/dist/layers-CM5i6T7z.d.mts +55 -0
- package/dist/layers-CM5i6T7z.d.ts +55 -0
- package/dist/markdown.cjs +4 -4
- package/dist/markdown.d.mts +5 -7
- package/dist/markdown.d.ts +5 -7
- package/dist/markdown.mjs +3 -3
- package/dist/middleware.cjs +16 -10
- package/dist/middleware.d.mts +7 -9
- package/dist/middleware.d.ts +7 -9
- package/dist/middleware.mjs +19 -13
- package/dist/navigation.cjs +4 -4
- package/dist/navigation.d.mts +8 -9
- package/dist/navigation.d.ts +8 -9
- package/dist/navigation.mjs +3 -3
- package/dist/{nitro-MPZJGPXK.mjs → nitro-NFG2LBRC.mjs} +3 -2
- package/dist/{nitro-7F65EZZS.cjs → nitro-S2QABUFA.cjs} +4 -3
- package/dist/observability.cjs +2 -2
- package/dist/observability.mjs +1 -1
- package/dist/plugin-DBBZ4JI2.cjs +32 -0
- package/dist/plugin-SYMK7PQ2.mjs +32 -0
- package/dist/plugin.cjs +55 -42
- package/dist/plugin.d.mts +23 -7
- package/dist/plugin.d.ts +23 -7
- package/dist/plugin.mjs +56 -43
- package/dist/{production-runtime-BaI3WHnV.d.ts → production-runtime-DfknD3g_.d.ts} +17 -3
- package/dist/{production-runtime-DfRP0cV0.d.mts → production-runtime-j_WCfuwB.d.mts} +17 -3
- package/dist/programmatic-routes-client-DcoxEaLe.d.mts +55 -0
- package/dist/programmatic-routes-client-DcoxEaLe.d.ts +55 -0
- package/dist/query/client.cjs +2 -2
- package/dist/query/client.mjs +1 -1
- package/dist/{render-plan-CfIdJKAf.d.ts → render-plan-CFIhcYYS.d.ts} +1 -1
- package/dist/{render-plan-Dg8RBYFa.d.mts → render-plan-ChUtsymc.d.mts} +1 -1
- package/dist/renderer-client.d.mts +7 -8
- package/dist/renderer-client.d.ts +7 -8
- package/dist/{request-DfE02G_A.d.mts → request-F4HRwzSd.d.mts} +1 -1
- package/dist/{request-CEbHIIl4.d.ts → request-RJvelT8L.d.ts} +1 -1
- package/dist/request.cjs +3 -3
- package/dist/request.d.mts +6 -8
- package/dist/request.d.ts +6 -8
- package/dist/request.mjs +2 -2
- package/dist/{route-rendering-C4oHbv6C.d.ts → route-rendering-3a4fbNyC.d.mts} +1 -1
- package/dist/{route-rendering-BHyOfXjD.d.mts → route-rendering-D4coJ-kw.d.ts} +1 -1
- package/dist/{router-DwhA61SB.d.mts → router-DqIssGRO.d.mts} +1 -1
- package/dist/{router-uRN_29Em.d.ts → router-WLEW3Te1.d.ts} +1 -1
- package/dist/routes.cjs +6 -5
- package/dist/routes.d.mts +5 -7
- package/dist/routes.d.ts +5 -7
- package/dist/routes.mjs +5 -4
- package/dist/{runtime-COk03hmx.d.ts → runtime-BrNdLOq9.d.ts} +3 -3
- package/dist/{runtime-BEdHhN4C.d.mts → runtime-CmE_j-js.d.mts} +3 -3
- package/dist/{schema-dev-notice-Y7MQEFGN.cjs → schema-dev-notice-5JPE67AI.cjs} +6 -4
- package/dist/{schema-dev-notice-O67CPXJ6.mjs → schema-dev-notice-WLPZ6WKU.mjs} +4 -2
- package/dist/server-action-security.cjs +4 -3
- package/dist/server-action-security.mjs +3 -2
- package/dist/server-client-bridge-DKWDl5NB.d.mts +7 -0
- package/dist/server-client-bridge-DKWDl5NB.d.ts +7 -0
- package/dist/server-fn-client.d.mts +3 -3
- package/dist/server-fn-client.d.ts +3 -3
- package/dist/server-fn.cjs +8 -7
- package/dist/server-fn.d.mts +1 -1
- package/dist/server-fn.d.ts +1 -1
- package/dist/server-fn.mjs +7 -6
- package/dist/server-plugins.cjs +5 -5
- package/dist/server-plugins.d.mts +6 -8
- package/dist/server-plugins.d.ts +6 -8
- package/dist/server-plugins.mjs +4 -4
- package/dist/server-query-client.d.mts +1 -1
- package/dist/server-query-client.d.ts +1 -1
- package/dist/server-query.cjs +9 -8
- package/dist/server-query.d.mts +1 -1
- package/dist/server-query.d.ts +1 -1
- package/dist/server-query.mjs +8 -7
- package/dist/server.cjs +96 -72
- package/dist/server.d.mts +16 -12
- package/dist/server.d.ts +16 -12
- package/dist/server.mjs +81 -57
- package/dist/{spa-router-w4aFOuyn.d.mts → spa-router-C41zjnFl.d.mts} +2 -2
- package/dist/{spa-router-DrVOBVGg.d.ts → spa-router-D_0VXqPC.d.ts} +2 -2
- package/dist/storage.cjs +6 -2
- package/dist/storage.d.mts +9 -1
- package/dist/storage.d.ts +9 -1
- package/dist/storage.mjs +5 -1
- package/dist/testing.cjs +20 -18
- package/dist/testing.d.mts +6 -8
- package/dist/testing.d.ts +6 -8
- package/dist/testing.mjs +16 -14
- package/dist/theme/server.cjs +4 -4
- package/dist/theme/server.mjs +3 -3
- package/dist/{utils-Dhuqwmd2.d.ts → utils-BKWSe3S7.d.mts} +1 -1
- package/dist/{utils-BtYehqeU.d.mts → utils-YYcWsOJp.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +57 -44
- package/dist/vite.d.mts +92 -10
- package/dist/vite.d.ts +92 -10
- package/dist/vite.mjs +58 -45
- package/dist/{workflows-jZ4BcdoZ.d.ts → workflows-IWP1ddBm.d.mts} +5 -2
- package/dist/{workflows-jZ4BcdoZ.d.mts → workflows-IWP1ddBm.d.ts} +5 -2
- package/dist/workflows.cjs +4 -3
- package/dist/workflows.d.mts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.mjs +3 -2
- package/package.json +2 -1
- package/dist/chunk-3SDFA7UF.cjs +0 -701
- package/dist/chunk-E5GNDG5F.mjs +0 -701
- package/dist/integration-orm-55F7CII5.cjs +0 -13
|
@@ -4,19 +4,20 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
FARM_NODE_ENV_MODULE_FILE,
|
|
6
6
|
FARM_NODE_ENV_MODULE_SOURCE,
|
|
7
|
+
createFarmBunServerEntry,
|
|
7
8
|
createFarmNodeServerEntry,
|
|
8
9
|
withProductionNodeEnv
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UIDWEU7M.mjs";
|
|
10
11
|
import {
|
|
11
12
|
generateNativeMCPPluginSource,
|
|
12
13
|
layoutsCanCoverSamePage
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-CKFK3Z2V.mjs";
|
|
14
15
|
import {
|
|
15
16
|
assertFarmDocsAdapterServesNoGuardedPages,
|
|
16
17
|
compileFarmDocsAdapterEdgeManifest,
|
|
17
18
|
createFarmDocsAPIHandler,
|
|
18
19
|
hasFarmDocsRuntimeAdapter
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-IMQO6ZUU.mjs";
|
|
20
21
|
import {
|
|
21
22
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
22
23
|
createFarmDocsHandler,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
loadFarmDocsPage,
|
|
28
29
|
resolveFarmDocsContentDir,
|
|
29
30
|
toFarmDocsMarkdownPage
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-HBEBV7OZ.mjs";
|
|
31
32
|
import {
|
|
32
33
|
generateFarmDocsSearchClientRuntime,
|
|
33
34
|
isFarmDocsSearchEnabled,
|
|
@@ -35,7 +36,7 @@ import {
|
|
|
35
36
|
} from "./chunk-UP4CW6WP.mjs";
|
|
36
37
|
import {
|
|
37
38
|
FARM_PRERENDER_ENV
|
|
38
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-YJBWB6GF.mjs";
|
|
39
40
|
import {
|
|
40
41
|
loadFarmDocsEngine
|
|
41
42
|
} from "./chunk-2VQKKQ6D.mjs";
|
|
@@ -44,7 +45,7 @@ import {
|
|
|
44
45
|
getDeployTargetForPreset,
|
|
45
46
|
hasCustomFarmRouteContext,
|
|
46
47
|
resolveDeployOutputPath
|
|
47
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-Y4QVEU67.mjs";
|
|
48
49
|
import {
|
|
49
50
|
resolveFarmInstrumentationFile
|
|
50
51
|
} from "./chunk-ZZSRYEYU.mjs";
|
|
@@ -54,7 +55,6 @@ import {
|
|
|
54
55
|
import {
|
|
55
56
|
DEFAULT_NOT_FOUND_STYLES,
|
|
56
57
|
FARM_LAYOUT_ELEMENT_CLIENT_SOURCE,
|
|
57
|
-
PluginManager,
|
|
58
58
|
SHARP_INSTALL_HINT,
|
|
59
59
|
collectFarmWebMCPTools,
|
|
60
60
|
createFarmApp,
|
|
@@ -65,7 +65,6 @@ import {
|
|
|
65
65
|
enforceFarmIsolatedHydrationRouteBudget,
|
|
66
66
|
farmDocsClientConfigPlugin,
|
|
67
67
|
farmFontImportsPlugin,
|
|
68
|
-
farmPluginMayAffectRuntimePath,
|
|
69
68
|
generateClientCachePersistenceCode,
|
|
70
69
|
generateFarmClientPluginEntryCode,
|
|
71
70
|
generateFarmIntegrationProviderClientCode,
|
|
@@ -83,13 +82,16 @@ import {
|
|
|
83
82
|
resolveFarmIsolatedClientHydrationMode,
|
|
84
83
|
resolveFarmNotFoundComponentPath,
|
|
85
84
|
usesFarmServerTree
|
|
86
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-FCOLU5P6.mjs";
|
|
86
|
+
import {
|
|
87
|
+
PluginManager
|
|
88
|
+
} from "./chunk-FGH3ZXTP.mjs";
|
|
87
89
|
import {
|
|
88
90
|
findRequestBoundSourceBlockers,
|
|
89
91
|
generateFarmTypeArtifacts,
|
|
90
92
|
parseRouteRenderingDirective,
|
|
91
93
|
resolveRouteRenderingConfigFromFile
|
|
92
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-BPGO2IEP.mjs";
|
|
93
95
|
import {
|
|
94
96
|
FARM_API_CATALOG_PATH,
|
|
95
97
|
FARM_APP_MANIFEST_LEGACY_PATH,
|
|
@@ -105,18 +107,21 @@ import {
|
|
|
105
107
|
resolveFarmAppManifestInput,
|
|
106
108
|
routeBoundaryCoversDirectory,
|
|
107
109
|
stripRouteGroups
|
|
108
|
-
} from "./chunk-
|
|
110
|
+
} from "./chunk-T6DLMX5V.mjs";
|
|
109
111
|
import {
|
|
110
112
|
FARM_DEFAULT_MCP_PATH,
|
|
111
113
|
createFarmDefaultMCPServer,
|
|
112
114
|
farmConfigMountsMCP
|
|
113
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-4ZZNPK25.mjs";
|
|
116
|
+
import {
|
|
117
|
+
farmPluginMayAffectRuntimePath
|
|
118
|
+
} from "./chunk-Y5RG6B7S.mjs";
|
|
114
119
|
import {
|
|
115
120
|
isFarmPreviewDeploymentEnvironment
|
|
116
121
|
} from "./chunk-BOYNDCZL.mjs";
|
|
117
122
|
import {
|
|
118
123
|
farmEnvironmentFunctionsPlugin
|
|
119
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-CALY6QG6.mjs";
|
|
120
125
|
import {
|
|
121
126
|
generateFarmDocsAdapterClientRuntime,
|
|
122
127
|
getFarmDocsAdapterConfigModule
|
|
@@ -128,9 +133,6 @@ import {
|
|
|
128
133
|
import {
|
|
129
134
|
routeRulesToNitroRouteRules
|
|
130
135
|
} from "./chunk-GHFS7RUB.mjs";
|
|
131
|
-
import {
|
|
132
|
-
getFarmAppDirectories
|
|
133
|
-
} from "./chunk-BUGNQIHC.mjs";
|
|
134
136
|
import {
|
|
135
137
|
REACT_RENDERER,
|
|
136
138
|
getFarmRendererCapabilities,
|
|
@@ -143,7 +145,10 @@ import {
|
|
|
143
145
|
import {
|
|
144
146
|
applyFarmCspHashesToHtml,
|
|
145
147
|
createFarmCspNonce
|
|
146
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-PNCM5MFD.mjs";
|
|
149
|
+
import {
|
|
150
|
+
getFarmAppDirectories
|
|
151
|
+
} from "./chunk-BUGNQIHC.mjs";
|
|
147
152
|
import {
|
|
148
153
|
applyFarmCronVercelCrons,
|
|
149
154
|
createFarmCronCloudflareConfig,
|
|
@@ -155,31 +160,34 @@ import {
|
|
|
155
160
|
} from "./chunk-4OOBRCJX.mjs";
|
|
156
161
|
import {
|
|
157
162
|
isFarmMarkdownPageFile
|
|
158
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-GZTUT75U.mjs";
|
|
159
164
|
import {
|
|
160
165
|
resolveFarmMdxComponentsModulePath,
|
|
161
166
|
resolveMdxConfig
|
|
162
167
|
} from "./chunk-FA2W42OV.mjs";
|
|
163
168
|
import {
|
|
164
169
|
getFarmMarkdownAlternatePath
|
|
165
|
-
} from "./chunk-
|
|
170
|
+
} from "./chunk-I6UVKUYK.mjs";
|
|
166
171
|
import {
|
|
167
172
|
applyFarmWorkflowVercelCrons,
|
|
168
173
|
prepareFarmWorkflowsForNitro
|
|
169
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-JXB6DVCO.mjs";
|
|
175
|
+
import {
|
|
176
|
+
_collectFarmStorageModules
|
|
177
|
+
} from "./chunk-JGHCKIRI.mjs";
|
|
170
178
|
import {
|
|
171
179
|
FARM_INTEGRATION_API_BASE_PATH_KEY,
|
|
172
180
|
getFarmIntegrationPluginServerRuntime,
|
|
173
181
|
getIntegrationProviders
|
|
174
|
-
} from "./chunk-
|
|
182
|
+
} from "./chunk-AX7S67YV.mjs";
|
|
175
183
|
import {
|
|
176
184
|
appendMiddlewareDirectory,
|
|
177
185
|
appendMiddlewareRoutePath,
|
|
178
186
|
compareMiddlewareRouteLocations
|
|
179
|
-
} from "./chunk-
|
|
187
|
+
} from "./chunk-LFHCG2DU.mjs";
|
|
180
188
|
import {
|
|
181
189
|
APIRouteManager
|
|
182
|
-
} from "./chunk-
|
|
190
|
+
} from "./chunk-T36UJS3X.mjs";
|
|
183
191
|
import {
|
|
184
192
|
readFarmI18nCatalogs
|
|
185
193
|
} from "./chunk-QCFBDFRS.mjs";
|
|
@@ -206,13 +214,13 @@ import {
|
|
|
206
214
|
} from "./chunk-BTHHUD7Q.mjs";
|
|
207
215
|
import {
|
|
208
216
|
FARM_VERSION
|
|
209
|
-
} from "./chunk-
|
|
217
|
+
} from "./chunk-H56MQYEG.mjs";
|
|
210
218
|
import {
|
|
211
219
|
getFarmPresetRuntime
|
|
212
220
|
} from "./chunk-2A3EQHXX.mjs";
|
|
213
221
|
import {
|
|
214
222
|
_runWithFarmCspNonce
|
|
215
|
-
} from "./chunk-
|
|
223
|
+
} from "./chunk-ZOABCQGT.mjs";
|
|
216
224
|
import {
|
|
217
225
|
compareRoutePatternSpecificity
|
|
218
226
|
} from "./chunk-55YI3RRB.mjs";
|
|
@@ -221,7 +229,7 @@ import {
|
|
|
221
229
|
} from "./chunk-LPEX4YW6.mjs";
|
|
222
230
|
|
|
223
231
|
// src/build/index.ts
|
|
224
|
-
import
|
|
232
|
+
import path10 from "path";
|
|
225
233
|
import { existsSync as existsSync3 } from "fs";
|
|
226
234
|
|
|
227
235
|
// src/nitro/client-css-href.ts
|
|
@@ -229,15 +237,15 @@ import path from "path";
|
|
|
229
237
|
var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
|
|
230
238
|
var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
|
|
231
239
|
async function hashAndCopy(sourcePath, destinationDir, hashedName) {
|
|
232
|
-
const
|
|
240
|
+
const fs4 = await import("fs/promises");
|
|
233
241
|
try {
|
|
234
|
-
const bytes = await
|
|
242
|
+
const bytes = await fs4.readFile(sourcePath);
|
|
235
243
|
if (bytes.length === 0) return null;
|
|
236
244
|
const { createHash } = await import("crypto");
|
|
237
245
|
const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
238
246
|
const name = hashedName(hash);
|
|
239
|
-
await
|
|
240
|
-
await
|
|
247
|
+
await fs4.mkdir(destinationDir, { recursive: true });
|
|
248
|
+
await fs4.writeFile(path.join(destinationDir, name), bytes);
|
|
241
249
|
return name;
|
|
242
250
|
} catch {
|
|
243
251
|
return null;
|
|
@@ -254,9 +262,9 @@ async function resolveHashedClientCssHref(clientOutputDir) {
|
|
|
254
262
|
}
|
|
255
263
|
__name(resolveHashedClientCssHref, "resolveHashedClientCssHref");
|
|
256
264
|
async function findFingerprintedClientEntry(clientOutputDir) {
|
|
257
|
-
const
|
|
265
|
+
const fs4 = await import("fs/promises");
|
|
258
266
|
try {
|
|
259
|
-
const entries = await
|
|
267
|
+
const entries = await fs4.readdir(clientOutputDir);
|
|
260
268
|
return entries.find((name) => /^farm-client-h[0-9a-f]+\.js$/.test(name)) ?? null;
|
|
261
269
|
} catch {
|
|
262
270
|
return null;
|
|
@@ -266,17 +274,17 @@ __name(findFingerprintedClientEntry, "findFingerprintedClientEntry");
|
|
|
266
274
|
async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
267
275
|
const entryName = await findFingerprintedClientEntry(clientOutputDir);
|
|
268
276
|
if (!entryName) return "/farm-client.js";
|
|
269
|
-
const
|
|
277
|
+
const fs4 = await import("fs/promises");
|
|
270
278
|
const shim = `export * from "./${entryName}";
|
|
271
279
|
`;
|
|
272
|
-
await
|
|
280
|
+
await fs4.writeFile(path.join(clientOutputDir, "farm-client.js"), shim);
|
|
273
281
|
return `/${entryName}`;
|
|
274
282
|
}
|
|
275
283
|
__name(resolveHashedClientJsSrc, "resolveHashedClientJsSrc");
|
|
276
284
|
|
|
277
285
|
// src/nitro/universal-build.ts
|
|
278
286
|
import os from "os";
|
|
279
|
-
import
|
|
287
|
+
import path9 from "path";
|
|
280
288
|
import { constants as fsConstants, existsSync as existsSync2, readFileSync, realpathSync, statSync } from "fs";
|
|
281
289
|
import { fileURLToPath } from "url";
|
|
282
290
|
import { builtinModules, createRequire } from "module";
|
|
@@ -704,10 +712,10 @@ async function createFarmRouteRuntimeManifest(options) {
|
|
|
704
712
|
}
|
|
705
713
|
__name(createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
|
|
706
714
|
async function writeFarmRouteRuntimeManifest(directory, manifest) {
|
|
707
|
-
const
|
|
715
|
+
const fs4 = await import("fs/promises");
|
|
708
716
|
const manifestPath = path5.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
|
|
709
|
-
await
|
|
710
|
-
await
|
|
717
|
+
await fs4.mkdir(directory, { recursive: true });
|
|
718
|
+
await fs4.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
711
719
|
`);
|
|
712
720
|
return manifestPath;
|
|
713
721
|
}
|
|
@@ -752,7 +760,7 @@ __name(normalizeManifestSource, "normalizeManifestSource");
|
|
|
752
760
|
|
|
753
761
|
// src/nitro/vercel-route-runtime.ts
|
|
754
762
|
import path6 from "path";
|
|
755
|
-
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest,
|
|
763
|
+
async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, basePath = "/") {
|
|
756
764
|
const dynamicRoutes = manifest.routes.filter(
|
|
757
765
|
(route) => route.rendering === "dynamic" && route.runtime !== "edge"
|
|
758
766
|
);
|
|
@@ -783,8 +791,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs3, b
|
|
|
783
791
|
groupIndex += 1;
|
|
784
792
|
const functionName = `__farm_runtime_${groupIndex}`;
|
|
785
793
|
const functionDir = path6.join(functionsDir, `${functionName}.func`);
|
|
786
|
-
await
|
|
787
|
-
await configureVercelFunction(functionDir, group.config,
|
|
794
|
+
await fs4.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
|
|
795
|
+
await configureVercelFunction(functionDir, group.config, fs4);
|
|
788
796
|
destinations.set(key, `/${functionName}`);
|
|
789
797
|
}
|
|
790
798
|
const routes = [];
|
|
@@ -798,17 +806,7 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs3, b
|
|
|
798
806
|
regions: route.regions,
|
|
799
807
|
maxDuration: route.maxDuration
|
|
800
808
|
});
|
|
801
|
-
routes.push({
|
|
802
|
-
src,
|
|
803
|
-
dest: destinations.get(key) || "/__nitro",
|
|
804
|
-
...route.kind === "api" || route.pattern.startsWith("/api/") ? {
|
|
805
|
-
headers: {
|
|
806
|
-
"Access-Control-Allow-Origin": "*",
|
|
807
|
-
"Access-Control-Allow-Methods": "*",
|
|
808
|
-
"Access-Control-Allow-Headers": "*"
|
|
809
|
-
}
|
|
810
|
-
} : {}
|
|
811
|
-
});
|
|
809
|
+
routes.push({ src, dest: destinations.get(key) || "/__nitro" });
|
|
812
810
|
}
|
|
813
811
|
return routes;
|
|
814
812
|
}
|
|
@@ -833,15 +831,15 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
|
|
|
833
831
|
return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
|
|
834
832
|
}
|
|
835
833
|
__name(farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
|
|
836
|
-
async function configureVercelFunction(functionDir, config,
|
|
834
|
+
async function configureVercelFunction(functionDir, config, fs4) {
|
|
837
835
|
const configPath = path6.join(functionDir, ".vc-config.json");
|
|
838
|
-
const current = JSON.parse(await
|
|
836
|
+
const current = JSON.parse(await fs4.readFile(configPath, "utf8"));
|
|
839
837
|
const next = {
|
|
840
838
|
...current,
|
|
841
839
|
...config.regions?.length ? { regions: config.regions } : {},
|
|
842
840
|
...config.maxDuration ? { maxDuration: config.maxDuration } : {}
|
|
843
841
|
};
|
|
844
|
-
await
|
|
842
|
+
await fs4.writeFile(configPath, `${JSON.stringify(next, null, 2)}
|
|
845
843
|
`);
|
|
846
844
|
}
|
|
847
845
|
__name(configureVercelFunction, "configureVercelFunction");
|
|
@@ -974,6 +972,39 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
974
972
|
}
|
|
975
973
|
__name(createFarmNetlifyEntry, "createFarmNetlifyEntry");
|
|
976
974
|
|
|
975
|
+
// src/nitro/client-sourcemaps.ts
|
|
976
|
+
import fs3 from "fs/promises";
|
|
977
|
+
import path8 from "path";
|
|
978
|
+
var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
|
|
979
|
+
function resolveFarmClientSourcemap(sourcemap) {
|
|
980
|
+
return sourcemap ? "hidden" : false;
|
|
981
|
+
}
|
|
982
|
+
__name(resolveFarmClientSourcemap, "resolveFarmClientSourcemap");
|
|
983
|
+
function createFarmPrivateClientSourcemapsPlugin(options) {
|
|
984
|
+
let maps = [];
|
|
985
|
+
return {
|
|
986
|
+
name: "farm-private-client-sourcemaps",
|
|
987
|
+
enforce: "post",
|
|
988
|
+
generateBundle(_output, bundle) {
|
|
989
|
+
maps = [];
|
|
990
|
+
for (const [fileName, output] of Object.entries(bundle)) {
|
|
991
|
+
if (output.type !== "asset" || !fileName.endsWith(".map")) continue;
|
|
992
|
+
maps.push([fileName, output.source ?? ""]);
|
|
993
|
+
delete bundle[fileName];
|
|
994
|
+
}
|
|
995
|
+
},
|
|
996
|
+
async writeBundle() {
|
|
997
|
+
await fs3.rm(options.outDir, { recursive: true, force: true });
|
|
998
|
+
for (const [fileName, source] of maps) {
|
|
999
|
+
const target = path8.join(options.outDir, fileName);
|
|
1000
|
+
await fs3.mkdir(path8.dirname(target), { recursive: true });
|
|
1001
|
+
await fs3.writeFile(target, source);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
__name(createFarmPrivateClientSourcemapsPlugin, "createFarmPrivateClientSourcemapsPlugin");
|
|
1007
|
+
|
|
977
1008
|
// src/nitro/universal-build.ts
|
|
978
1009
|
function preloadFarmNitroBuilder() {
|
|
979
1010
|
return import("nitro/builder").then(
|
|
@@ -983,18 +1014,18 @@ function preloadFarmNitroBuilder() {
|
|
|
983
1014
|
}
|
|
984
1015
|
__name(preloadFarmNitroBuilder, "preloadFarmNitroBuilder");
|
|
985
1016
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
986
|
-
var _dirname =
|
|
1017
|
+
var _dirname = path9.dirname(_filename);
|
|
987
1018
|
function findFarmCoreRoot(from) {
|
|
988
|
-
let dir =
|
|
989
|
-
while (dir !==
|
|
990
|
-
const manifest =
|
|
1019
|
+
let dir = path9.dirname(from);
|
|
1020
|
+
while (dir !== path9.dirname(dir)) {
|
|
1021
|
+
const manifest = path9.join(dir, "package.json");
|
|
991
1022
|
if (existsSync2(manifest)) {
|
|
992
1023
|
try {
|
|
993
1024
|
if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
994
1025
|
} catch {
|
|
995
1026
|
}
|
|
996
1027
|
}
|
|
997
|
-
dir =
|
|
1028
|
+
dir = path9.dirname(dir);
|
|
998
1029
|
}
|
|
999
1030
|
return null;
|
|
1000
1031
|
}
|
|
@@ -1006,16 +1037,16 @@ function toModulePath(file) {
|
|
|
1006
1037
|
}
|
|
1007
1038
|
__name(toModulePath, "toModulePath");
|
|
1008
1039
|
function findInstalledPackageDir(name, from) {
|
|
1009
|
-
for (let dir = from; ; dir =
|
|
1010
|
-
const candidate =
|
|
1011
|
-
if (existsSync2(
|
|
1040
|
+
for (let dir = from; ; dir = path9.dirname(dir)) {
|
|
1041
|
+
const candidate = path9.join(dir, "node_modules", name);
|
|
1042
|
+
if (existsSync2(path9.join(candidate, "package.json"))) {
|
|
1012
1043
|
try {
|
|
1013
1044
|
return realpathSync(candidate);
|
|
1014
1045
|
} catch {
|
|
1015
1046
|
return null;
|
|
1016
1047
|
}
|
|
1017
1048
|
}
|
|
1018
|
-
if (dir ===
|
|
1049
|
+
if (dir === path9.dirname(dir)) return null;
|
|
1019
1050
|
}
|
|
1020
1051
|
}
|
|
1021
1052
|
__name(findInstalledPackageDir, "findInstalledPackageDir");
|
|
@@ -1027,7 +1058,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1027
1058
|
seen.add(dir);
|
|
1028
1059
|
let manifest;
|
|
1029
1060
|
try {
|
|
1030
|
-
manifest = JSON.parse(readFileSync(
|
|
1061
|
+
manifest = JSON.parse(readFileSync(path9.join(dir, "package.json"), "utf8"));
|
|
1031
1062
|
} catch {
|
|
1032
1063
|
return;
|
|
1033
1064
|
}
|
|
@@ -1038,7 +1069,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1038
1069
|
if (farmCoreRoot) visit(realpathSync(farmCoreRoot));
|
|
1039
1070
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1040
1071
|
try {
|
|
1041
|
-
const manifest = JSON.parse(readFileSync(
|
|
1072
|
+
const manifest = JSON.parse(readFileSync(path9.join(root, "package.json"), "utf8"));
|
|
1042
1073
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1043
1074
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1044
1075
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1105,15 +1136,15 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1105
1136
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1106
1137
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1107
1138
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1108
|
-
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
1139
|
+
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(path9.sep).join("/");
|
|
1109
1140
|
}
|
|
1110
1141
|
__name(resolveNitroRuntimeDependency, "resolveNitroRuntimeDependency");
|
|
1111
1142
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1112
|
-
const runtimeDir =
|
|
1143
|
+
const runtimeDir = path9.dirname(resolveNitroPackageEntry(root));
|
|
1113
1144
|
return Object.fromEntries(
|
|
1114
1145
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1115
1146
|
`#nitro/runtime/${moduleName}`,
|
|
1116
|
-
|
|
1147
|
+
path9.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path9.sep).join("/")
|
|
1117
1148
|
])
|
|
1118
1149
|
);
|
|
1119
1150
|
}
|
|
@@ -1124,7 +1155,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1124
1155
|
name: "farm-prerender-runtime-resolver",
|
|
1125
1156
|
async resolveId(id, _importer, options) {
|
|
1126
1157
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1127
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
1158
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path9.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1128
1159
|
return null;
|
|
1129
1160
|
}
|
|
1130
1161
|
if (nitroEntry === void 0) {
|
|
@@ -1144,8 +1175,39 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1144
1175
|
};
|
|
1145
1176
|
}
|
|
1146
1177
|
__name(createPrerenderRuntimeResolverPlugin, "createPrerenderRuntimeResolverPlugin");
|
|
1178
|
+
function createFarmStorageModuleRegistration(config) {
|
|
1179
|
+
const modules = _collectFarmStorageModules(config.storage);
|
|
1180
|
+
if (modules.length === 0) return "";
|
|
1181
|
+
const root = config.root || process.cwd();
|
|
1182
|
+
const projectRequire = createRequire(path9.join(root, "package.json"));
|
|
1183
|
+
let runtimeRequire = projectRequire;
|
|
1184
|
+
try {
|
|
1185
|
+
runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
|
|
1186
|
+
} catch {
|
|
1187
|
+
}
|
|
1188
|
+
const loaders = [];
|
|
1189
|
+
for (const specifier of modules) {
|
|
1190
|
+
let resolved;
|
|
1191
|
+
for (const require2 of [runtimeRequire, projectRequire]) {
|
|
1192
|
+
try {
|
|
1193
|
+
resolved = require2.resolve(specifier);
|
|
1194
|
+
break;
|
|
1195
|
+
} catch {
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
if (resolved) {
|
|
1199
|
+
loaders.push(
|
|
1200
|
+
` ${JSON.stringify(specifier)}: () => import(${toVirtualEntryImportSpecifier(resolved)}),`
|
|
1201
|
+
);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return loaders.length > 0 ? `_registerFarmStorageModules({
|
|
1205
|
+
${loaders.join("\n")}
|
|
1206
|
+
});` : "";
|
|
1207
|
+
}
|
|
1208
|
+
__name(createFarmStorageModuleRegistration, "createFarmStorageModuleRegistration");
|
|
1147
1209
|
function resolveNitroPackageEntry(root) {
|
|
1148
|
-
const projectRequire = createRequire(
|
|
1210
|
+
const projectRequire = createRequire(path9.join(root, "package.json"));
|
|
1149
1211
|
let runtimeRequire = projectRequire;
|
|
1150
1212
|
try {
|
|
1151
1213
|
runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1220,7 +1282,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1220
1282
|
__name(createFarmReactWebServerAlias, "createFarmReactWebServerAlias");
|
|
1221
1283
|
function hasReactDomEdgeServerBuild(root) {
|
|
1222
1284
|
try {
|
|
1223
|
-
createRequire(
|
|
1285
|
+
createRequire(path9.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1224
1286
|
return true;
|
|
1225
1287
|
} catch {
|
|
1226
1288
|
return false;
|
|
@@ -1270,6 +1332,45 @@ function createReactProductionModePlugin() {
|
|
|
1270
1332
|
};
|
|
1271
1333
|
}
|
|
1272
1334
|
__name(createReactProductionModePlugin, "createReactProductionModePlugin");
|
|
1335
|
+
var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
|
|
1336
|
+
function isFarmCoreModule(file) {
|
|
1337
|
+
let dir = path9.dirname(file.split("?", 1)[0]);
|
|
1338
|
+
while (dir !== path9.dirname(dir)) {
|
|
1339
|
+
const manifest = path9.join(dir, "package.json");
|
|
1340
|
+
if (existsSync2(manifest)) {
|
|
1341
|
+
try {
|
|
1342
|
+
return JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core";
|
|
1343
|
+
} catch {
|
|
1344
|
+
return false;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
dir = path9.dirname(dir);
|
|
1348
|
+
}
|
|
1349
|
+
return false;
|
|
1350
|
+
}
|
|
1351
|
+
__name(isFarmCoreModule, "isFarmCoreModule");
|
|
1352
|
+
function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
|
|
1353
|
+
return {
|
|
1354
|
+
name: "farm-omitted-metadata-image-runtime",
|
|
1355
|
+
resolveId(source, importer) {
|
|
1356
|
+
if (source !== "@vercel/og") return null;
|
|
1357
|
+
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path9.basename(importer.split("?", 1)[0]));
|
|
1358
|
+
if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
|
|
1359
|
+
return externalizeOtherImports ? { id: source, external: true } : null;
|
|
1360
|
+
},
|
|
1361
|
+
load(id) {
|
|
1362
|
+
if (id !== FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID) return null;
|
|
1363
|
+
return `
|
|
1364
|
+
export class ImageResponse {
|
|
1365
|
+
constructor() {
|
|
1366
|
+
throw new Error("@vercel/og is not in this server build because the app has no generated metadata image route.");
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
`;
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
__name(createOmittedMetadataImageRuntimePlugin, "createOmittedMetadataImageRuntimePlugin");
|
|
1273
1374
|
function createMetadataImageWasmPlugin() {
|
|
1274
1375
|
return {
|
|
1275
1376
|
name: "farm-metadata-image-wasm",
|
|
@@ -1278,7 +1379,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
1278
1379
|
return null;
|
|
1279
1380
|
}
|
|
1280
1381
|
const requestPath = source.slice(0, -"?module".length);
|
|
1281
|
-
const resolvedPath =
|
|
1382
|
+
const resolvedPath = path9.isAbsolute(requestPath) ? requestPath : path9.resolve(path9.dirname(importer.split("?", 1)[0]), requestPath);
|
|
1282
1383
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
1283
1384
|
},
|
|
1284
1385
|
load(id) {
|
|
@@ -1304,11 +1405,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1304
1405
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
1305
1406
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
1306
1407
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
1307
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
1408
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path9.posix.normalize(path9.posix.join(path9.posix.dirname(fileName), normalizedImportId)) : null;
|
|
1308
1409
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
1309
1410
|
continue;
|
|
1310
1411
|
}
|
|
1311
|
-
if (
|
|
1412
|
+
if (path9.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
1312
1413
|
externalPackages.add(importId);
|
|
1313
1414
|
continue;
|
|
1314
1415
|
}
|
|
@@ -1321,15 +1422,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1321
1422
|
}
|
|
1322
1423
|
__name(collectSSRExternalPackages, "collectSSRExternalPackages");
|
|
1323
1424
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
1324
|
-
const resolvedNitroEntry =
|
|
1325
|
-
const resolvedSSREntry =
|
|
1425
|
+
const resolvedNitroEntry = path9.resolve(nitroEntryPath);
|
|
1426
|
+
const resolvedSSREntry = path9.resolve(ssrOutputDir, ssrEntryFile);
|
|
1326
1427
|
return {
|
|
1327
1428
|
name: "farm-externalize-prebuilt-ssr",
|
|
1328
1429
|
resolveId(source, importer) {
|
|
1329
|
-
if (!importer ||
|
|
1430
|
+
if (!importer || path9.resolve(importer) !== resolvedNitroEntry) {
|
|
1330
1431
|
return null;
|
|
1331
1432
|
}
|
|
1332
|
-
const resolvedImport =
|
|
1433
|
+
const resolvedImport = path9.resolve(path9.dirname(importer), source);
|
|
1333
1434
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
1334
1435
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
1335
1436
|
}
|
|
@@ -1348,6 +1449,10 @@ function hasFarmServerCacheConfig(cache) {
|
|
|
1348
1449
|
return cache.adapter !== void 0 || cache.namespace !== void 0 || cache.maxEntries !== void 0 || cache.lease !== void 0;
|
|
1349
1450
|
}
|
|
1350
1451
|
__name(hasFarmServerCacheConfig, "hasFarmServerCacheConfig");
|
|
1452
|
+
function hasFarmServerStorageConfig(storage) {
|
|
1453
|
+
return !!storage && typeof storage === "object" && Reflect.ownKeys(storage).length > 0;
|
|
1454
|
+
}
|
|
1455
|
+
__name(hasFarmServerStorageConfig, "hasFarmServerStorageConfig");
|
|
1351
1456
|
function hasFarmRuntimeConfigModule(config, configModulePath) {
|
|
1352
1457
|
return Boolean(configModulePath || (config.layers || []).some((layer) => layer.configFile));
|
|
1353
1458
|
}
|
|
@@ -1457,13 +1562,13 @@ function resolveBuildDocsContentDir(config, root) {
|
|
|
1457
1562
|
if (!config.docs?.enabled) return null;
|
|
1458
1563
|
const configuredContentDir = config.docs.contentDir || config.docs.config.contentDir;
|
|
1459
1564
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
1460
|
-
const contentDir =
|
|
1565
|
+
const contentDir = path9.isAbsolute(configuredContentDir) ? configuredContentDir : path9.join(root, configuredContentDir);
|
|
1461
1566
|
return existsSync2(contentDir) ? contentDir : null;
|
|
1462
1567
|
}
|
|
1463
1568
|
const entryDir = config.docs.config.entry || trimSlashes(config.docs.entry) || "docs";
|
|
1464
|
-
const appDocsDir =
|
|
1569
|
+
const appDocsDir = path9.join(root, config.srcDir || "src", "app", entryDir);
|
|
1465
1570
|
if (existsSync2(appDocsDir)) return appDocsDir;
|
|
1466
|
-
const rootDocsDir =
|
|
1571
|
+
const rootDocsDir = path9.join(root, entryDir);
|
|
1467
1572
|
return existsSync2(rootDocsDir) ? rootDocsDir : null;
|
|
1468
1573
|
}
|
|
1469
1574
|
__name(resolveBuildDocsContentDir, "resolveBuildDocsContentDir");
|
|
@@ -1481,7 +1586,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
1481
1586
|
".postcssrc.mjs",
|
|
1482
1587
|
".postcssrc.ts"
|
|
1483
1588
|
];
|
|
1484
|
-
const projectRequire = createRequire(
|
|
1589
|
+
const projectRequire = createRequire(path9.join(root, "package.json"));
|
|
1485
1590
|
return candidates.some((file) => {
|
|
1486
1591
|
try {
|
|
1487
1592
|
projectRequire.resolve(`./${file}`);
|
|
@@ -1493,7 +1598,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
1493
1598
|
}
|
|
1494
1599
|
__name(hasProjectPostcssConfig, "hasProjectPostcssConfig");
|
|
1495
1600
|
async function findFarmConfigPath(root) {
|
|
1496
|
-
const
|
|
1601
|
+
const fs4 = await import("fs/promises");
|
|
1497
1602
|
const candidates = [
|
|
1498
1603
|
"farm.config.ts",
|
|
1499
1604
|
"farm.config.mts",
|
|
@@ -1505,9 +1610,9 @@ async function findFarmConfigPath(root) {
|
|
|
1505
1610
|
"config.mjs"
|
|
1506
1611
|
];
|
|
1507
1612
|
for (const candidate of candidates) {
|
|
1508
|
-
const resolvedPath =
|
|
1613
|
+
const resolvedPath = path9.join(root, candidate);
|
|
1509
1614
|
try {
|
|
1510
|
-
await
|
|
1615
|
+
await fs4.access(resolvedPath);
|
|
1511
1616
|
return resolvedPath;
|
|
1512
1617
|
} catch {
|
|
1513
1618
|
}
|
|
@@ -1535,13 +1640,13 @@ function farmServerRuntimePluginsMayHandlePath(config, pathname) {
|
|
|
1535
1640
|
}
|
|
1536
1641
|
__name(farmServerRuntimePluginsMayHandlePath, "farmServerRuntimePluginsMayHandlePath");
|
|
1537
1642
|
async function discoverMiddlewareRoutes(appDir) {
|
|
1538
|
-
const
|
|
1643
|
+
const fs4 = await import("fs/promises");
|
|
1539
1644
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
1540
1645
|
const routes = /* @__PURE__ */ new Map();
|
|
1541
1646
|
async function walk(dir, routePath, directory, discovered) {
|
|
1542
1647
|
let entries;
|
|
1543
1648
|
try {
|
|
1544
|
-
entries = await
|
|
1649
|
+
entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
1545
1650
|
} catch {
|
|
1546
1651
|
return;
|
|
1547
1652
|
}
|
|
@@ -1552,7 +1657,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1552
1657
|
discovered.push({
|
|
1553
1658
|
path: routePath,
|
|
1554
1659
|
directory,
|
|
1555
|
-
filePath:
|
|
1660
|
+
filePath: path9.join(dir, middlewareFile.name)
|
|
1556
1661
|
});
|
|
1557
1662
|
}
|
|
1558
1663
|
for (const entry of entries) {
|
|
@@ -1560,7 +1665,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1560
1665
|
continue;
|
|
1561
1666
|
}
|
|
1562
1667
|
await walk(
|
|
1563
|
-
|
|
1668
|
+
path9.join(dir, entry.name),
|
|
1564
1669
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
1565
1670
|
appendMiddlewareDirectory(directory, entry.name),
|
|
1566
1671
|
discovered
|
|
@@ -1637,21 +1742,21 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1637
1742
|
})
|
|
1638
1743
|
);
|
|
1639
1744
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
1640
|
-
const
|
|
1745
|
+
const fs4 = await import("fs/promises");
|
|
1641
1746
|
const layoutRoutes = [];
|
|
1642
|
-
const appDir =
|
|
1747
|
+
const appDir = path9.join(root, srcDir, "app");
|
|
1643
1748
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
1644
1749
|
try {
|
|
1645
|
-
const entries = await
|
|
1750
|
+
const entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
1646
1751
|
for (const entry of entries) {
|
|
1647
1752
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
1648
1753
|
layoutRoutes.push({
|
|
1649
1754
|
pattern: routePrefix,
|
|
1650
|
-
modulePath:
|
|
1755
|
+
modulePath: path9.join(dir, entry.name)
|
|
1651
1756
|
});
|
|
1652
1757
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
1653
1758
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
1654
|
-
await findLayoutsForClient(
|
|
1759
|
+
await findLayoutsForClient(path9.join(dir, entry.name), childPrefix);
|
|
1655
1760
|
}
|
|
1656
1761
|
}
|
|
1657
1762
|
} catch {
|
|
@@ -1668,7 +1773,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1668
1773
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes and ${layoutRoutes.length} layouts`);
|
|
1669
1774
|
const isolatedClientBoundaryModules = routeManager.getIsolatedClientBoundaryModules(root);
|
|
1670
1775
|
const hydrationPlanCache = /* @__PURE__ */ new Map();
|
|
1671
|
-
const clientOutputDir =
|
|
1776
|
+
const clientOutputDir = path9.join(root, distDir, "client");
|
|
1672
1777
|
const [productionViteResult] = await productionViteResultPromise;
|
|
1673
1778
|
if (productionViteResult.status === "rejected") {
|
|
1674
1779
|
await routeRuntimeManifestResultPromise;
|
|
@@ -1687,7 +1792,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1687
1792
|
routeSlots,
|
|
1688
1793
|
isolatedClientBoundaryModules,
|
|
1689
1794
|
hydrationPlanCache,
|
|
1690
|
-
rendererBuildLifetime
|
|
1795
|
+
rendererBuildLifetime,
|
|
1796
|
+
routeManager.getProgrammaticClientRoutes()
|
|
1691
1797
|
), "buildClientBundle");
|
|
1692
1798
|
const buildSSRBundle = /* @__PURE__ */ __name(() => buildSSRInMemory(
|
|
1693
1799
|
productionVite,
|
|
@@ -1739,7 +1845,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1739
1845
|
routeSlots,
|
|
1740
1846
|
isolatedClientBoundaryModules,
|
|
1741
1847
|
hydrationPlanCache,
|
|
1742
|
-
rendererBuildLifetime
|
|
1848
|
+
rendererBuildLifetime,
|
|
1849
|
+
routeManager.getProgrammaticClientRoutes()
|
|
1743
1850
|
);
|
|
1744
1851
|
} catch (retryError) {
|
|
1745
1852
|
if (!(retryError instanceof IncompleteClientBuildOutputError)) throw retryError;
|
|
@@ -1777,10 +1884,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1777
1884
|
lifecyclePluginManager
|
|
1778
1885
|
);
|
|
1779
1886
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
1780
|
-
|
|
1887
|
+
path9.join(root, distDir),
|
|
1781
1888
|
routeRuntimeManifest
|
|
1782
1889
|
);
|
|
1783
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
1890
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path9.relative(root, runtimeManifestPath)}`);
|
|
1784
1891
|
} catch (error) {
|
|
1785
1892
|
if (lifecyclePluginManager) {
|
|
1786
1893
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -1800,50 +1907,50 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1800
1907
|
}
|
|
1801
1908
|
__name(buildUniversal, "buildUniversal");
|
|
1802
1909
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
1803
|
-
const
|
|
1910
|
+
const fs4 = await import("fs/promises");
|
|
1804
1911
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
1805
1912
|
if (output.type !== "asset") continue;
|
|
1806
1913
|
if (fileName === "farm-fonts.css") {
|
|
1807
1914
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
1808
1915
|
continue;
|
|
1809
1916
|
}
|
|
1810
|
-
const filePath =
|
|
1811
|
-
await
|
|
1812
|
-
await
|
|
1917
|
+
const filePath = path9.join(outputDir, fileName);
|
|
1918
|
+
await fs4.mkdir(path9.dirname(filePath), { recursive: true });
|
|
1919
|
+
await fs4.writeFile(filePath, output.source);
|
|
1813
1920
|
}
|
|
1814
1921
|
}
|
|
1815
1922
|
__name(writeSSRAssetsToClient, "writeSSRAssetsToClient");
|
|
1816
1923
|
async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
1817
|
-
const
|
|
1924
|
+
const fs4 = await import("fs/promises");
|
|
1818
1925
|
await Promise.all(
|
|
1819
1926
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
1820
|
-
const targetPath =
|
|
1821
|
-
await
|
|
1822
|
-
await
|
|
1927
|
+
const targetPath = path9.join(outputDir, url.replace(/^\/+/, ""));
|
|
1928
|
+
await fs4.mkdir(path9.dirname(targetPath), { recursive: true });
|
|
1929
|
+
await fs4.copyFile(sourcePath, targetPath);
|
|
1823
1930
|
})
|
|
1824
1931
|
);
|
|
1825
1932
|
}
|
|
1826
1933
|
__name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
|
|
1827
1934
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
1828
|
-
const
|
|
1829
|
-
const fontCssPath =
|
|
1935
|
+
const fs4 = await import("fs/promises");
|
|
1936
|
+
const fontCssPath = path9.join(outputDir, "farm-fonts.css");
|
|
1830
1937
|
let fontCss = fontCssSource;
|
|
1831
1938
|
if (fontCss === void 0) {
|
|
1832
1939
|
try {
|
|
1833
|
-
fontCss = await
|
|
1940
|
+
fontCss = await fs4.readFile(fontCssPath);
|
|
1834
1941
|
} catch {
|
|
1835
1942
|
return;
|
|
1836
1943
|
}
|
|
1837
1944
|
}
|
|
1838
|
-
const clientCssPath =
|
|
1945
|
+
const clientCssPath = path9.join(outputDir, "farm-client.css");
|
|
1839
1946
|
let clientCss = "";
|
|
1840
1947
|
try {
|
|
1841
|
-
clientCss = await
|
|
1948
|
+
clientCss = await fs4.readFile(clientCssPath, "utf8");
|
|
1842
1949
|
} catch {
|
|
1843
1950
|
}
|
|
1844
1951
|
const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
|
|
1845
|
-
await
|
|
1846
|
-
await
|
|
1952
|
+
await fs4.writeFile(fontCssPath, normalizedFontCss);
|
|
1953
|
+
await fs4.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
|
|
1847
1954
|
}
|
|
1848
1955
|
__name(mergeBuiltFontCss, "mergeBuiltFontCss");
|
|
1849
1956
|
var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
|
|
@@ -1855,28 +1962,28 @@ var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError
|
|
|
1855
1962
|
__name(_IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
|
|
1856
1963
|
var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
|
|
1857
1964
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
1858
|
-
const
|
|
1965
|
+
const fs4 = await import("fs/promises");
|
|
1859
1966
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
1860
|
-
const clientEntryPath =
|
|
1967
|
+
const clientEntryPath = path9.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
1861
1968
|
let clientEntrySize = 0;
|
|
1862
1969
|
try {
|
|
1863
|
-
const clientEntry = await
|
|
1970
|
+
const clientEntry = await fs4.stat(clientEntryPath);
|
|
1864
1971
|
if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
|
|
1865
1972
|
} catch {
|
|
1866
1973
|
}
|
|
1867
1974
|
if (clientEntrySize === 0) {
|
|
1868
1975
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
1869
1976
|
}
|
|
1870
|
-
const clientCssPath =
|
|
1871
|
-
const globalsCssPath =
|
|
1977
|
+
const clientCssPath = path9.join(outputDir, "farm-client.css");
|
|
1978
|
+
const globalsCssPath = path9.join(root, srcDir, "app", "globals.css");
|
|
1872
1979
|
let expectsCss = false;
|
|
1873
1980
|
try {
|
|
1874
|
-
const globalsCss = await
|
|
1981
|
+
const globalsCss = await fs4.readFile(globalsCssPath, "utf8");
|
|
1875
1982
|
expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1876
1983
|
} catch {
|
|
1877
1984
|
}
|
|
1878
1985
|
try {
|
|
1879
|
-
const clientCss = await
|
|
1986
|
+
const clientCss = await fs4.stat(clientCssPath);
|
|
1880
1987
|
if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
|
|
1881
1988
|
throw new IncompleteClientBuildOutputError("farm-client.css is empty");
|
|
1882
1989
|
}
|
|
@@ -1885,12 +1992,12 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
1885
1992
|
if (expectsCss) {
|
|
1886
1993
|
throw new IncompleteClientBuildOutputError("farm-client.css is missing");
|
|
1887
1994
|
}
|
|
1888
|
-
await
|
|
1995
|
+
await fs4.writeFile(clientCssPath, "");
|
|
1889
1996
|
}
|
|
1890
1997
|
}
|
|
1891
1998
|
__name(validateClientBuildOutput, "validateClientBuildOutput");
|
|
1892
1999
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
1893
|
-
const key = `${
|
|
2000
|
+
const key = `${path9.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${path9.resolve(modulePath)}`;
|
|
1894
2001
|
let plan = cache.get(key);
|
|
1895
2002
|
if (!plan) {
|
|
1896
2003
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -1899,11 +2006,11 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
1899
2006
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
1900
2007
|
}
|
|
1901
2008
|
__name(getCachedClientModuleHydrationPlan, "getCachedClientModuleHydrationPlan");
|
|
1902
|
-
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime) {
|
|
2009
|
+
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes) {
|
|
1903
2010
|
const viteBuild = productionVite.build;
|
|
1904
2011
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
1905
|
-
const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
|
|
1906
|
-
const
|
|
2012
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SYMK7PQ2.mjs");
|
|
2013
|
+
const fs4 = await import("fs/promises");
|
|
1907
2014
|
const pluginManager = new PluginManager2({
|
|
1908
2015
|
config,
|
|
1909
2016
|
isDev: false,
|
|
@@ -2129,10 +2236,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2129
2236
|
logger.info(
|
|
2130
2237
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2131
2238
|
);
|
|
2132
|
-
const clientEntryRoot =
|
|
2133
|
-
await
|
|
2134
|
-
const clientEntryDir = await
|
|
2135
|
-
const clientEntryPath =
|
|
2239
|
+
const clientEntryRoot = path9.join(root, ".farm", "tmp");
|
|
2240
|
+
await fs4.mkdir(clientEntryRoot, { recursive: true });
|
|
2241
|
+
const clientEntryDir = await fs4.mkdtemp(path9.join(clientEntryRoot, "client-entry-"));
|
|
2242
|
+
const clientEntryPath = path9.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2136
2243
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2137
2244
|
clientPages,
|
|
2138
2245
|
clientLayouts,
|
|
@@ -2153,7 +2260,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2153
2260
|
generateClientCachePersistenceCode(resolveFarmClientCacheAdapterEntry(root, config.cache)),
|
|
2154
2261
|
adapterOwnsDocsRuntime ? getFarmDocsAdapterConfigModule(config.docs) : void 0
|
|
2155
2262
|
);
|
|
2156
|
-
await
|
|
2263
|
+
await fs4.writeFile(clientEntryPath, clientHydrationCode);
|
|
2157
2264
|
const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
|
|
2158
2265
|
let postcssSearchPath;
|
|
2159
2266
|
let tailwindVitePlugin = void 0;
|
|
@@ -2164,8 +2271,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2164
2271
|
if (hasScopedPostcssConfig) {
|
|
2165
2272
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
2166
2273
|
} else {
|
|
2167
|
-
const postcssConfigPath =
|
|
2168
|
-
await
|
|
2274
|
+
const postcssConfigPath = path9.join(clientEntryDir, "postcss.config.cjs");
|
|
2275
|
+
await fs4.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
2169
2276
|
postcssSearchPath = clientEntryDir;
|
|
2170
2277
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
2171
2278
|
builder: productionVite.builder,
|
|
@@ -2187,6 +2294,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2187
2294
|
target: FARM_CLIENT_BUILD_TARGET,
|
|
2188
2295
|
outDir: outputDir,
|
|
2189
2296
|
emptyOutDir: true,
|
|
2297
|
+
// Never public: see resolveFarmClientSourcemap.
|
|
2298
|
+
sourcemap: resolveFarmClientSourcemap(config.vite?.build?.sourcemap),
|
|
2190
2299
|
assetsInlineLimit: 0,
|
|
2191
2300
|
cssCodeSplit: false,
|
|
2192
2301
|
// Bundle all CSS into one file
|
|
@@ -2237,15 +2346,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2237
2346
|
},
|
|
2238
2347
|
plugins: [
|
|
2239
2348
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
2349
|
+
createFarmPrivateClientSourcemapsPlugin({
|
|
2350
|
+
outDir: path9.join(path9.dirname(outputDir), FARM_CLIENT_SOURCEMAPS_DIR)
|
|
2351
|
+
}),
|
|
2240
2352
|
createFarmClientModulePreloadPlugin({
|
|
2241
2353
|
root,
|
|
2242
|
-
buildDir:
|
|
2354
|
+
buildDir: path9.dirname(outputDir),
|
|
2243
2355
|
entryName: "farm-client"
|
|
2244
2356
|
}),
|
|
2245
2357
|
...adapterOwnsDocsRuntime ? [
|
|
2246
2358
|
createFarmDocsModulePreloadPlugin({
|
|
2247
2359
|
root,
|
|
2248
|
-
buildDir:
|
|
2360
|
+
buildDir: path9.dirname(outputDir),
|
|
2249
2361
|
importer: clientEntryPath,
|
|
2250
2362
|
entryName: "farm-client",
|
|
2251
2363
|
modules: [
|
|
@@ -2308,8 +2420,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2308
2420
|
return null;
|
|
2309
2421
|
}
|
|
2310
2422
|
},
|
|
2311
|
-
farmPlugin(
|
|
2312
|
-
|
|
2423
|
+
farmPlugin(
|
|
2424
|
+
{ ...config, isolatedClientBoundaryModules, programmaticClientRoutes },
|
|
2425
|
+
pluginManager
|
|
2426
|
+
),
|
|
2427
|
+
farmEnvironmentFunctionsPlugin(config)
|
|
2313
2428
|
],
|
|
2314
2429
|
mode: "production",
|
|
2315
2430
|
css: postcssSearchPath ? {
|
|
@@ -2335,7 +2450,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2335
2450
|
await validateClientBuildOutput(root, srcDir, outputDir);
|
|
2336
2451
|
} finally {
|
|
2337
2452
|
try {
|
|
2338
|
-
await
|
|
2453
|
+
await fs4.rm(clientEntryDir, { recursive: true, force: true });
|
|
2339
2454
|
} catch {
|
|
2340
2455
|
}
|
|
2341
2456
|
}
|
|
@@ -2343,12 +2458,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2343
2458
|
__name(buildClient, "buildClient");
|
|
2344
2459
|
function toBakedMarkdownSourcePath(root, filePath) {
|
|
2345
2460
|
if (!filePath) return "";
|
|
2346
|
-
if (!
|
|
2347
|
-
const relative =
|
|
2348
|
-
if (!relative || relative.startsWith("..") ||
|
|
2349
|
-
return
|
|
2461
|
+
if (!path9.isAbsolute(filePath)) return filePath.split(path9.sep).join("/");
|
|
2462
|
+
const relative = path9.relative(root, filePath);
|
|
2463
|
+
if (!relative || relative.startsWith("..") || path9.isAbsolute(relative)) {
|
|
2464
|
+
return path9.basename(filePath);
|
|
2350
2465
|
}
|
|
2351
|
-
return relative.split(
|
|
2466
|
+
return relative.split(path9.sep).join("/");
|
|
2352
2467
|
}
|
|
2353
2468
|
__name(toBakedMarkdownSourcePath, "toBakedMarkdownSourcePath");
|
|
2354
2469
|
function generateUniversalRouterStateRuntime() {
|
|
@@ -3105,7 +3220,7 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
3105
3220
|
root,
|
|
3106
3221
|
renderer.componentExtensions ?? []
|
|
3107
3222
|
);
|
|
3108
|
-
const globalsCssPath =
|
|
3223
|
+
const globalsCssPath = path9.join(root, srcDir, "app", "globals.css");
|
|
3109
3224
|
const cssImport = existsSync2(globalsCssPath) ? `import ${JSON.stringify(toImportPath(globalsCssPath))};` : "";
|
|
3110
3225
|
const layoutImportStatements = [];
|
|
3111
3226
|
const layoutRegistrations = [];
|
|
@@ -4578,8 +4693,8 @@ __name(generateClientHydrationEntry, "generateClientHydrationEntry");
|
|
|
4578
4693
|
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
|
|
4579
4694
|
const viteBuild = productionVite.build;
|
|
4580
4695
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
4581
|
-
const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
|
|
4582
|
-
const
|
|
4696
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SYMK7PQ2.mjs");
|
|
4697
|
+
const fs4 = await import("fs/promises");
|
|
4583
4698
|
const pluginManager = new PluginManager2({
|
|
4584
4699
|
config,
|
|
4585
4700
|
isDev: false,
|
|
@@ -4594,9 +4709,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4594
4709
|
buildLifetime: rendererBuildLifetime
|
|
4595
4710
|
});
|
|
4596
4711
|
if (!hasScopedPostcssConfig) {
|
|
4597
|
-
postcssConfigDir = await
|
|
4598
|
-
await
|
|
4599
|
-
|
|
4712
|
+
postcssConfigDir = await fs4.mkdtemp(path9.join(os.tmpdir(), "farm-postcss-"));
|
|
4713
|
+
await fs4.writeFile(
|
|
4714
|
+
path9.join(postcssConfigDir, "postcss.config.cjs"),
|
|
4600
4715
|
"module.exports = { plugins: [] };\n"
|
|
4601
4716
|
);
|
|
4602
4717
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -4621,7 +4736,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4621
4736
|
fileName: entry.fileName,
|
|
4622
4737
|
sourceType: "static",
|
|
4623
4738
|
staticInfo: entry.staticInfo,
|
|
4624
|
-
data: (await
|
|
4739
|
+
data: (await fs4.readFile(entry.modulePath)).toString("base64")
|
|
4625
4740
|
});
|
|
4626
4741
|
continue;
|
|
4627
4742
|
}
|
|
@@ -4722,7 +4837,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4722
4837
|
const hasServerRuntimePlugins = hasFarmServerRuntimePlugins(config);
|
|
4723
4838
|
const hasPluginRoutes = hasFarmPluginRoutes(config);
|
|
4724
4839
|
const hasServerCacheConfig = hasFarmServerCacheConfig(config.cache);
|
|
4725
|
-
const configModulePath = hasServerRuntimeIntegrations || hasObservabilityHandler || hasMdxComponentConfig || hasMiddlewareConfig || hasRouteContextConfig || hasServerRuntimePlugins || hasPluginRoutes || hasServerCacheConfig || hasIntegrationProviders ? await findFarmConfigPath(root) : null;
|
|
4840
|
+
const configModulePath = hasServerRuntimeIntegrations || hasObservabilityHandler || hasMdxComponentConfig || hasMiddlewareConfig || hasRouteContextConfig || hasServerRuntimePlugins || hasPluginRoutes || hasServerCacheConfig || hasFarmServerStorageConfig(config.storage) || hasIntegrationProviders ? await findFarmConfigPath(root) : null;
|
|
4726
4841
|
const hasRuntimeConfigModule = hasFarmRuntimeConfigModule(config, configModulePath);
|
|
4727
4842
|
const hasRuntimeIntegrationConfig = hasRuntimeConfigModule && hasAnyConfiguredIntegrations;
|
|
4728
4843
|
const hasConfiguredRuntimePlugins = Boolean(
|
|
@@ -4790,6 +4905,10 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4790
4905
|
);
|
|
4791
4906
|
const virtualEntryId = "\0virtual:farm-ssr-entry";
|
|
4792
4907
|
const useExternalMetadataImageRuntime = shouldUseExternalMetadataImageRuntime(preset, true);
|
|
4908
|
+
const omitCoreMetadataImageRuntime = !metadataImageRoutes.some(
|
|
4909
|
+
(image) => image.sourceType === "module"
|
|
4910
|
+
);
|
|
4911
|
+
const externalMetadataImageRuntime = useExternalMetadataImageRuntime && !omitCoreMetadataImageRuntime ? ["@vercel/og"] : [];
|
|
4793
4912
|
const rendererOptionalExternals = isReactRenderer(config.renderer) ? [] : [
|
|
4794
4913
|
"react",
|
|
4795
4914
|
"react/jsx-runtime",
|
|
@@ -4823,7 +4942,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4823
4942
|
// startup; kept external, Nitro copies the package into the output.
|
|
4824
4943
|
"better-sqlite3",
|
|
4825
4944
|
...rendererOptionalExternals,
|
|
4826
|
-
...
|
|
4945
|
+
...externalMetadataImageRuntime,
|
|
4827
4946
|
"@prisma/client",
|
|
4828
4947
|
"@prisma/client/default",
|
|
4829
4948
|
"@prisma/client/default.js",
|
|
@@ -4855,7 +4974,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4855
4974
|
"fsevents",
|
|
4856
4975
|
"sharp",
|
|
4857
4976
|
...rendererOptionalExternals,
|
|
4858
|
-
...
|
|
4977
|
+
...externalMetadataImageRuntime,
|
|
4859
4978
|
"esbuild",
|
|
4860
4979
|
"lightningcss",
|
|
4861
4980
|
"rolldown",
|
|
@@ -4902,10 +5021,16 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4902
5021
|
...rendererVitePlugins,
|
|
4903
5022
|
...config.vite.plugins || [],
|
|
4904
5023
|
...!useExternalMetadataImageRuntime && metadataImageRoutes.some((image) => image.sourceType === "module") ? [createMetadataImageWasmPlugin()] : [],
|
|
5024
|
+
...omitCoreMetadataImageRuntime ? [
|
|
5025
|
+
{
|
|
5026
|
+
...createOmittedMetadataImageRuntimePlugin(useExternalMetadataImageRuntime),
|
|
5027
|
+
enforce: "pre"
|
|
5028
|
+
}
|
|
5029
|
+
] : [],
|
|
4905
5030
|
{ ...createReactProductionModePlugin(), enforce: "pre" },
|
|
4906
5031
|
farmServerOnlyEntriesPlugin(),
|
|
4907
5032
|
farmPlugin({ ...config, isolatedClientBoundaryModules }, pluginManager),
|
|
4908
|
-
farmEnvironmentFunctionsPlugin(),
|
|
5033
|
+
farmEnvironmentFunctionsPlugin(config),
|
|
4909
5034
|
{
|
|
4910
5035
|
name: "farm-virtual-ssr-entry",
|
|
4911
5036
|
resolveId(id) {
|
|
@@ -4956,7 +5081,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4956
5081
|
} finally {
|
|
4957
5082
|
if (postcssConfigDir) {
|
|
4958
5083
|
try {
|
|
4959
|
-
await
|
|
5084
|
+
await fs4.rm(postcssConfigDir, { recursive: true, force: true });
|
|
4960
5085
|
} catch {
|
|
4961
5086
|
}
|
|
4962
5087
|
}
|
|
@@ -4970,7 +5095,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4970
5095
|
__name(buildSSRInMemory, "buildSSRInMemory");
|
|
4971
5096
|
function readFarmAppPackageIdentity(root) {
|
|
4972
5097
|
try {
|
|
4973
|
-
return JSON.parse(readFileSync(
|
|
5098
|
+
return JSON.parse(readFileSync(path9.join(root, "package.json"), "utf8"));
|
|
4974
5099
|
} catch {
|
|
4975
5100
|
return {};
|
|
4976
5101
|
}
|
|
@@ -5077,7 +5202,7 @@ function matchLocalIntegrationRequest(request) {
|
|
|
5077
5202
|
});` : "return null;"}
|
|
5078
5203
|
}
|
|
5079
5204
|
|
|
5080
|
-
async function handleIntegrationRequest(request, ranMiddleware) {
|
|
5205
|
+
async function handleIntegrationRequest(request, ranMiddleware, clientAddress) {
|
|
5081
5206
|
${options.hasServerRuntimeIntegrations ? `return dispatchIntegrationRequests(
|
|
5082
5207
|
serverRuntimeIntegrations,
|
|
5083
5208
|
{
|
|
@@ -5086,7 +5211,7 @@ async function handleIntegrationRequest(request, ranMiddleware) {
|
|
|
5086
5211
|
isProd: true,
|
|
5087
5212
|
},
|
|
5088
5213
|
request,
|
|
5089
|
-
{ ranMiddleware },
|
|
5214
|
+
{ ranMiddleware, clientAddress },
|
|
5090
5215
|
);` : `return { response: null, setCookies: [] };`}
|
|
5091
5216
|
}
|
|
5092
5217
|
|
|
@@ -5721,6 +5846,8 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5721
5846
|
createFarmProductionLifecycle,
|
|
5722
5847
|
createFarmNodeRequestAbortSignal,
|
|
5723
5848
|
createProductionMiddlewareRunner,
|
|
5849
|
+
_withFarmGuardedResponseCache,
|
|
5850
|
+
_farmPluginsKeepResponsesPrivate,
|
|
5724
5851
|
getTheme as getFarmTheme,
|
|
5725
5852
|
emitFarmEvent,
|
|
5726
5853
|
getFarmDataCache,
|
|
@@ -5758,7 +5885,7 @@ function renderFarmRouteServerTree(element) { return element; }`;
|
|
|
5758
5885
|
stripFarmLocaleFromPathname,
|
|
5759
5886
|
withFarmRouteContext,
|
|
5760
5887
|
createLateNotFoundRecovery,
|
|
5761
|
-
createLateRedirectRecovery,
|
|
5888
|
+
createLateRedirectRecovery,${hasFarmServerStorageConfig(config.storage) ? "\n _registerFarmStorageModules,\n disposeFarmStorage,\n initFarmStorage," : ""}
|
|
5762
5889
|
} from "@farm.js/core/internal/production-runtime";`;
|
|
5763
5890
|
const productionSiteTelemetryImport = config.telemetry ? `import { createFarmProductionSiteReporter } from "@farm.js/core/internal/product-telemetry-runtime";` : "";
|
|
5764
5891
|
const metadataImageRuntimeImport = hasGeneratedMetadataImages ? `import { createFarmMetadataImageResponse } from "@farm.js/core/internal/metadata-image-runtime";` : "";
|
|
@@ -5784,7 +5911,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
5784
5911
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
5785
5912
|
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;";
|
|
5786
5913
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
5787
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
5914
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path9.isAbsolute(config.mdx.components) ? config.mdx.components : path9.join(config.root, config.mdx.components) : null;
|
|
5788
5915
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
5789
5916
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
5790
5917
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -5811,7 +5938,7 @@ ${nativeAuth.importSource}
|
|
|
5811
5938
|
${nativeMCP.importSource}
|
|
5812
5939
|
`;
|
|
5813
5940
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
5814
|
-
const imageRuntimeImport = imageRuntime === "none" ? "" : `import { createCloudflareImageTransformer, createFarmImageHandler } from "@farm.js/core/image/server";`;
|
|
5941
|
+
const imageRuntimeImport = imageRuntime === "none" ? "" : `import { _withFarmImageSourceClientAddress, createCloudflareImageTransformer, createFarmImageHandler } from "@farm.js/core/image/server";`;
|
|
5815
5942
|
const imageNodeRuntimeImport = imageRuntime === "node" ? `import { createNodeImageFetcher, createNodeImageUrlValidator, createSharpImageTransformer } from "@farm.js/core/image/sharp";` : "";
|
|
5816
5943
|
const apiHandlerCode = apiRoutes.length > 0 ? `
|
|
5817
5944
|
const matchBuiltAPIRoute = createStaticAPIRouteMatcherAtBasePath(apiRoutes, farmLocalAPIBasePath);
|
|
@@ -6105,6 +6232,10 @@ const farmPluginRuntime = ${hasPluginRuntime ? `configuredPlugins.length > 0
|
|
|
6105
6232
|
return manager;
|
|
6106
6233
|
})()
|
|
6107
6234
|
: null` : "null"};
|
|
6235
|
+
// A plugin's runtime.before runs for every request and may be a guard, like middleware.
|
|
6236
|
+
const farmPluginRuntimeKeepsResponsesPrivate = farmPluginRuntime
|
|
6237
|
+
? _farmPluginsKeepResponsesPrivate(configuredPlugins)
|
|
6238
|
+
: false;
|
|
6108
6239
|
const hasFarmPluginHTMLTransforms = configuredPlugins.some(
|
|
6109
6240
|
(plugin) => plugin.render?.html || plugin.afterRender || plugin.transformHTML,
|
|
6110
6241
|
);
|
|
@@ -6138,6 +6269,7 @@ const farmObservabilityConfig = farmUserConfig?.observability ?? ${JSON.stringif
|
|
|
6138
6269
|
)};
|
|
6139
6270
|
configureFarmObservability(farmObservabilityConfig);
|
|
6140
6271
|
configureFarmCache(farmResolvedRuntimeConfig.cache);
|
|
6272
|
+
${createFarmStorageModuleRegistration(config)}
|
|
6141
6273
|
const farmI18nConfig = ${JSON.stringify(config.i18n)};
|
|
6142
6274
|
const farmServerConfig = ${JSON.stringify(config.server)};
|
|
6143
6275
|
const farmThemeConfig = ${JSON.stringify(config.theme)};
|
|
@@ -6156,9 +6288,11 @@ export const farmProductionLifecycle = createFarmProductionLifecycle({
|
|
|
6156
6288
|
server: farmServerConfig,
|
|
6157
6289
|
start: async () => {
|
|
6158
6290
|
await farmInstrumentationLifecycle.start();
|
|
6159
|
-
try {
|
|
6291
|
+
try {${hasFarmServerStorageConfig(config.storage) ? `
|
|
6292
|
+
// The configured drivers and mounts, as the development server applies them.
|
|
6293
|
+
await initFarmStorage(farmResolvedRuntimeConfig.storage);` : ""}
|
|
6160
6294
|
await farmPluginRuntime?.startRuntime();
|
|
6161
|
-
} catch (error) {
|
|
6295
|
+
} catch (error) {${hasFarmServerStorageConfig(config.storage) ? "\n await disposeFarmStorage();" : ""}
|
|
6162
6296
|
await farmInstrumentationLifecycle.shutdown();
|
|
6163
6297
|
throw error;
|
|
6164
6298
|
}
|
|
@@ -6166,7 +6300,7 @@ export const farmProductionLifecycle = createFarmProductionLifecycle({
|
|
|
6166
6300
|
close: async (reason) => {
|
|
6167
6301
|
try {
|
|
6168
6302
|
await farmPluginRuntime?.closeRuntime(reason);${hasInfraAnalyticsRuntime && !hasPluginRuntime ? "\n await farmInfraAnalytics?.close();" : ""}
|
|
6169
|
-
} finally {
|
|
6303
|
+
} finally {${hasFarmServerStorageConfig(config.storage) ? "\n await disposeFarmStorage();" : ""}
|
|
6170
6304
|
await farmInstrumentationLifecycle.shutdown();
|
|
6171
6305
|
}
|
|
6172
6306
|
},
|
|
@@ -6264,7 +6398,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
6264
6398
|
|
|
6265
6399
|
// API routes bundled at build time
|
|
6266
6400
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
6267
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
6401
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path11, methods }) => ({ path: path11, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
6268
6402
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
6269
6403
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
6270
6404
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -7872,7 +8006,8 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
|
|
|
7872
8006
|
});
|
|
7873
8007
|
}` : ""}
|
|
7874
8008
|
|
|
7875
|
-
|
|
8009
|
+
// Shells keep their own LRU so query-string variants never evict app cache entries.
|
|
8010
|
+
const pprShellCache = getFarmDataCache().pprShellCache;
|
|
7876
8011
|
const experimentalPPREnabled = ${JSON.stringify(config.experimental?.ppr === true)};
|
|
7877
8012
|
|
|
7878
8013
|
function resolveRouteRenderingView(route) {
|
|
@@ -8016,6 +8151,10 @@ async function handleFarmRequest(request, adapterContext) {
|
|
|
8016
8151
|
return response;
|
|
8017
8152
|
}
|
|
8018
8153
|
|
|
8154
|
+
// Middleware that let a request through may have been a guard: an IP allowlist, an API key
|
|
8155
|
+
// header, a VPN header. A CDN keys its copy by URL and never runs the guard on a hit, so
|
|
8156
|
+
// whatever such a request answers stays out of shared caches. Only middleware declaring
|
|
8157
|
+
// cache: "public" (and plugins declaring runtime.cache: "public") leave the policy alone.
|
|
8019
8158
|
async function handleFarmRequestInContext(
|
|
8020
8159
|
request,
|
|
8021
8160
|
farmLocaleResolution,
|
|
@@ -8023,6 +8162,31 @@ async function handleFarmRequestInContext(
|
|
|
8023
8162
|
requestStartTime = Date.now(),
|
|
8024
8163
|
adapterContext,
|
|
8025
8164
|
requestUrl = new URL(request.url),
|
|
8165
|
+
) {
|
|
8166
|
+
const farmCacheGuard = { guarded: farmPluginRuntimeKeepsResponsesPrivate };
|
|
8167
|
+
const response = await resolveFarmRequestInContext(
|
|
8168
|
+
farmCacheGuard,
|
|
8169
|
+
request,
|
|
8170
|
+
farmLocaleResolution,
|
|
8171
|
+
configuredRewriteApplied,
|
|
8172
|
+
requestStartTime,
|
|
8173
|
+
adapterContext,
|
|
8174
|
+
requestUrl,
|
|
8175
|
+
);
|
|
8176
|
+
if (!farmCacheGuard.guarded) return response;
|
|
8177
|
+
// Tells the Nitro entry, which keeps this policy over a swr rule's public one.
|
|
8178
|
+
adapterContext?.onGuardedResponse?.();
|
|
8179
|
+
return _withFarmGuardedResponseCache(response);
|
|
8180
|
+
}
|
|
8181
|
+
|
|
8182
|
+
async function resolveFarmRequestInContext(
|
|
8183
|
+
farmCacheGuard,
|
|
8184
|
+
request,
|
|
8185
|
+
farmLocaleResolution,
|
|
8186
|
+
configuredRewriteApplied,
|
|
8187
|
+
requestStartTime,
|
|
8188
|
+
adapterContext,
|
|
8189
|
+
requestUrl,
|
|
8026
8190
|
) {
|
|
8027
8191
|
let url = requestUrl;
|
|
8028
8192
|
let pathname = url.pathname;
|
|
@@ -8055,10 +8219,26 @@ async function handleFarmRequestInContext(
|
|
|
8055
8219
|
farmLocaleResolution?.locale,
|
|
8056
8220
|
);
|
|
8057
8221
|
if (rewriteDestination) {
|
|
8058
|
-
|
|
8222
|
+
let rewrittenRequest = createRewrittenRequest(request, rewriteDestination);
|
|
8059
8223
|
if (new URL(rewrittenRequest.url).origin !== url.origin) {
|
|
8060
8224
|
return globalThis.fetch(rewrittenRequest);
|
|
8061
8225
|
}
|
|
8226
|
+
if (farmPluginRuntime) {
|
|
8227
|
+
// Plugin guards ran on the requested URL. Re-run only runtime.before
|
|
8228
|
+
// so they also see the destination, like middleware does on re-entry.
|
|
8229
|
+
const guarded = await farmPluginRuntime.runRuntimeBeforeForRewrite(
|
|
8230
|
+
request,
|
|
8231
|
+
rewrittenRequest,
|
|
8232
|
+
{
|
|
8233
|
+
...getFarmPluginRequestOptions(rewrittenRequest),
|
|
8234
|
+
waitUntil: typeof adapterContext?.waitUntil === "function"
|
|
8235
|
+
? adapterContext.waitUntil.bind(adapterContext)
|
|
8236
|
+
: undefined,
|
|
8237
|
+
},
|
|
8238
|
+
);
|
|
8239
|
+
if (guarded instanceof Response) return guarded;
|
|
8240
|
+
rewrittenRequest = guarded;
|
|
8241
|
+
}
|
|
8062
8242
|
return _runWithCurrentRequest(rewrittenRequest, () =>
|
|
8063
8243
|
handleFarmRequestInContext(
|
|
8064
8244
|
rewrittenRequest,
|
|
@@ -8086,6 +8266,7 @@ async function handleFarmRequestInContext(
|
|
|
8086
8266
|
const integrationDispatch = await handleIntegrationRequest(
|
|
8087
8267
|
cloneFarmRequestWithContext(request),
|
|
8088
8268
|
farmIntegrationRanMiddleware,
|
|
8269
|
+
adapterContext?.clientAddress,
|
|
8089
8270
|
);
|
|
8090
8271
|
if (integrationDispatch.response) {
|
|
8091
8272
|
return integrationDispatch.response;
|
|
@@ -8105,6 +8286,7 @@ async function handleFarmRequestInContext(
|
|
|
8105
8286
|
if (middlewareResult.response) {
|
|
8106
8287
|
return middlewareResult.response;
|
|
8107
8288
|
}
|
|
8289
|
+
if (middlewareResult.guarded) farmCacheGuard.guarded = true;
|
|
8108
8290
|
request = middlewareResult.request;${hasServerRuntimeIntegrations ? `
|
|
8109
8291
|
// A ctx.rewrite() target is guarded as a direct request for it is: integration
|
|
8110
8292
|
// guards (protectedRoutes) and routes see the rewritten URL, as in dev. Guards
|
|
@@ -8113,6 +8295,7 @@ async function handleFarmRequestInContext(
|
|
|
8113
8295
|
const rewrittenDispatch = await handleIntegrationRequest(
|
|
8114
8296
|
cloneFarmRequestWithContext(request),
|
|
8115
8297
|
farmIntegrationRanMiddleware,
|
|
8298
|
+
adapterContext?.clientAddress,
|
|
8116
8299
|
);
|
|
8117
8300
|
farmIntegrationSetCookies = [...farmIntegrationSetCookies, ...rewrittenDispatch.setCookies];
|
|
8118
8301
|
if (rewrittenDispatch.response) {
|
|
@@ -8122,6 +8305,9 @@ async function handleFarmRequestInContext(
|
|
|
8122
8305
|
);
|
|
8123
8306
|
}
|
|
8124
8307
|
}` : ""}
|
|
8308
|
+
${hasServerRuntimeIntegrations ? `
|
|
8309
|
+
// An integration guard (protectedRoutes) that let the request through.
|
|
8310
|
+
if (farmIntegrationRanMiddleware.size > 0) farmCacheGuard.guarded = true;` : ""}
|
|
8125
8311
|
const middlewareData = middlewareResult.data;
|
|
8126
8312
|
const middlewareContext = middlewareResult.context;
|
|
8127
8313
|
const middlewareHeaders = ${hasServerRuntimeIntegrations ? "withFarmIntegrationSetCookies(middlewareResult.headers, farmIntegrationSetCookies)" : "middlewareResult.headers"};
|
|
@@ -8139,6 +8325,9 @@ async function handleFarmRequestInContext(
|
|
|
8139
8325
|
const runResolvedRequest = async () => {
|
|
8140
8326
|
if (middlewareResult.notFound) return renderFarmNotFoundResponse();
|
|
8141
8327
|
` : `
|
|
8328
|
+
${hasServerRuntimeIntegrations ? `
|
|
8329
|
+
// An integration guard (protectedRoutes) that let the request through.
|
|
8330
|
+
if (farmIntegrationRanMiddleware.size > 0) farmCacheGuard.guarded = true;` : ""}
|
|
8142
8331
|
const middlewareData = undefined;
|
|
8143
8332
|
const middlewareContext = undefined;
|
|
8144
8333
|
const middlewareHeaders = ${hasServerRuntimeIntegrations ? "withFarmIntegrationSetCookies(undefined, farmIntegrationSetCookies)" : "undefined"};
|
|
@@ -9521,7 +9710,9 @@ async function handleFarmPluginRequest(request, runtimeOptions, adapterContext)
|
|
|
9521
9710
|
${generatePreloadResponseRuntimeSource()}
|
|
9522
9711
|
|
|
9523
9712
|
// Export as Web Standard fetch API
|
|
9524
|
-
export async function fetch(request, context) {
|
|
9713
|
+
export async function fetch(request, context) {${imageRuntime === "none" ? "" : `
|
|
9714
|
+
// The image optimizer's fetch of a local source is not a loopback visitor.
|
|
9715
|
+
context = _withFarmImageSourceClientAddress(request, context);`}
|
|
9525
9716
|
${config.agent?.noindexPreviews ? "const response = await" : "return"} _runWithAPIRequestRuntime({
|
|
9526
9717
|
basePath: farmLocalAPIBasePath,
|
|
9527
9718
|
dispatch: async (localRequest) =>
|
|
@@ -9543,6 +9734,20 @@ async function handleFarmFetch(request, context) {
|
|
|
9543
9734
|
typeof context?.waitUntil === "function" ? context.waitUntil.bind(context) : undefined,
|
|
9544
9735
|
);
|
|
9545
9736
|
|
|
9737
|
+
// headers() config applies after middleware let the request through, so it learns
|
|
9738
|
+
// whether the response was guarded and can't make that response shareable again.
|
|
9739
|
+
let farmGuardedResponse = false;
|
|
9740
|
+
if (configuredHeaderRoutes.length > 0) {
|
|
9741
|
+
const adapterContext = context;
|
|
9742
|
+
context = {
|
|
9743
|
+
...adapterContext,
|
|
9744
|
+
onGuardedResponse() {
|
|
9745
|
+
farmGuardedResponse = true;
|
|
9746
|
+
adapterContext?.onGuardedResponse?.();
|
|
9747
|
+
},
|
|
9748
|
+
};
|
|
9749
|
+
}
|
|
9750
|
+
|
|
9546
9751
|
return farmProductionLifecycle.runRequest(
|
|
9547
9752
|
() =>
|
|
9548
9753
|
runWithFarmRequestSpan(request, async () => {
|
|
@@ -9557,9 +9762,11 @@ async function handleFarmFetch(request, context) {
|
|
|
9557
9762
|
const routePathname = configuredHeaderRoutes.length > 0
|
|
9558
9763
|
? getFarmRoutePathname(new URL(runtimeRequest.url).pathname)
|
|
9559
9764
|
: undefined;
|
|
9765
|
+
const configured = applyConfiguredResponseHeaders(response, routePathname);
|
|
9560
9766
|
return applyFarmPreloadBudget(
|
|
9561
9767
|
applyFarmCspNonceToResponse(
|
|
9562
|
-
|
|
9768
|
+
// Configured headers may edit the response in place, so check it either way.
|
|
9769
|
+
farmGuardedResponse ? _withFarmGuardedResponseCache(configured) : configured,
|
|
9563
9770
|
farmSecurityConfig,
|
|
9564
9771
|
cspNonce,
|
|
9565
9772
|
),
|
|
@@ -9723,8 +9930,17 @@ function getPhysicalPrerenderBypassReason(options) {
|
|
|
9723
9930
|
return void 0;
|
|
9724
9931
|
}
|
|
9725
9932
|
__name(getPhysicalPrerenderBypassReason, "getPhysicalPrerenderBypassReason");
|
|
9933
|
+
function hasFarmNitroCacheRouteRule(routeRules) {
|
|
9934
|
+
return Object.values(routeRules || {}).some((rule) => {
|
|
9935
|
+
const swr = rule?.swr;
|
|
9936
|
+
const cache = rule?.cache;
|
|
9937
|
+
const headers = rule?.headers;
|
|
9938
|
+
return swr !== void 0 && swr !== false || cache !== void 0 && cache !== false || !!headers && typeof headers === "object" && Object.keys(headers).length > 0;
|
|
9939
|
+
});
|
|
9940
|
+
}
|
|
9941
|
+
__name(hasFarmNitroCacheRouteRule, "hasFarmNitroCacheRouteRule");
|
|
9726
9942
|
async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager) {
|
|
9727
|
-
const [
|
|
9943
|
+
const [fs4, nitroBuilderResult] = await Promise.all([
|
|
9728
9944
|
import("fs/promises"),
|
|
9729
9945
|
nitroBuilderResultPromise
|
|
9730
9946
|
]);
|
|
@@ -9733,8 +9949,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9733
9949
|
const isVercel = preset === "vercel" || preset === "vercel-edge";
|
|
9734
9950
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
9735
9951
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
9736
|
-
const runtimeServerOutputDir = isVercel ?
|
|
9737
|
-
const ssrOutputDir =
|
|
9952
|
+
const runtimeServerOutputDir = isVercel ? path9.join(outputDir, "functions", "__nitro.func") : path9.join(outputDir, "server");
|
|
9953
|
+
const ssrOutputDir = path9.join(root, distDir, "ssr");
|
|
9738
9954
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
9739
9955
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
9740
9956
|
(image) => image.sourceType === "module"
|
|
@@ -9806,8 +10022,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9806
10022
|
const [clientCssHref, clientJsSrc, docsModulePreloads, clientModulePreloads] = await Promise.all([
|
|
9807
10023
|
resolveHashedClientCssHref(clientOutputDir),
|
|
9808
10024
|
resolveHashedClientJsSrc(clientOutputDir),
|
|
9809
|
-
readFarmDocsModulePreloads(
|
|
9810
|
-
readFarmClientModulePreloads(
|
|
10025
|
+
readFarmDocsModulePreloads(path9.join(root, distDir)),
|
|
10026
|
+
readFarmClientModulePreloads(path9.join(root, distDir))
|
|
9811
10027
|
]);
|
|
9812
10028
|
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
9813
10029
|
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
@@ -9826,14 +10042,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9826
10042
|
output.code = output.code.split(FARM_CLIENT_JS_SRC_PLACEHOLDER).join(clientJsSrc);
|
|
9827
10043
|
}
|
|
9828
10044
|
}
|
|
9829
|
-
await
|
|
10045
|
+
await fs4.mkdir(ssrOutputDir, { recursive: true });
|
|
9830
10046
|
for (const [fileName, output] of Object.entries(ssrBundle)) {
|
|
9831
|
-
const filePath =
|
|
9832
|
-
await
|
|
9833
|
-
await
|
|
10047
|
+
const filePath = path9.join(ssrOutputDir, fileName);
|
|
10048
|
+
await fs4.mkdir(path9.dirname(filePath), { recursive: true });
|
|
10049
|
+
await fs4.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
9834
10050
|
}
|
|
9835
|
-
const nitroEntryPath =
|
|
10051
|
+
const nitroEntryPath = path9.join(ssrOutputDir, "nitro-entry.mjs");
|
|
9836
10052
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
10053
|
+
const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
|
|
9837
10054
|
const nitroEntryCode = `
|
|
9838
10055
|
// Farm.js Nitro Entry
|
|
9839
10056
|
// This file adapts Farm's Web fetch handler to Nitro's event handler contract.
|
|
@@ -9854,7 +10071,39 @@ function registerFarmCloseHook() {
|
|
|
9854
10071
|
farmProductionLifecycle.close('production-server-closed')
|
|
9855
10072
|
)
|
|
9856
10073
|
}
|
|
9857
|
-
|
|
10074
|
+
${hasNitroCacheRouteRules ? `
|
|
10075
|
+
// A swr route rule caches through Nitro, which writes its own public Cache-Control on
|
|
10076
|
+
// the event after Farm answered, and a headers route rule sets its headers there too. H3
|
|
10077
|
+
// lets those replace the response's. A response middleware let through keeps Farm's
|
|
10078
|
+
// private policy and no CDN cache header, so no CDN serves it to others.
|
|
10079
|
+
const FARM_PRIVATE_CACHE_DIRECTIVE = /(?:^|,)\\s*(?:private|no-store)\\s*(?:[,=]|$)/i
|
|
10080
|
+
const FARM_CDN_CACHE_CONTROL_HEADERS = [
|
|
10081
|
+
'cdn-cache-control',
|
|
10082
|
+
'vercel-cdn-cache-control',
|
|
10083
|
+
'netlify-cdn-cache-control',
|
|
10084
|
+
'cloudflare-cdn-cache-control',
|
|
10085
|
+
]
|
|
10086
|
+
const farmPrivateCacheControlKey = Symbol.for('farm.privateCacheControl')
|
|
10087
|
+
let farmPrivateCacheHookRegistered = false
|
|
10088
|
+
function keepFarmPrivateCacheControl(event, cacheControl) {
|
|
10089
|
+
if (!farmPrivateCacheHookRegistered) {
|
|
10090
|
+
farmPrivateCacheHookRegistered = true
|
|
10091
|
+
useNitroHooks().hook('response', (response, responseEvent) => {
|
|
10092
|
+
const value = responseEvent.context?.[farmPrivateCacheControlKey]
|
|
10093
|
+
if (!value) return
|
|
10094
|
+
try {
|
|
10095
|
+
if (response.headers.get('cache-control') !== value) {
|
|
10096
|
+
response.headers.set('cache-control', value)
|
|
10097
|
+
}
|
|
10098
|
+
for (const name of FARM_CDN_CACHE_CONTROL_HEADERS) response.headers.delete(name)
|
|
10099
|
+
} catch {
|
|
10100
|
+
// Immutable headers belong to a response Nitro passed through untouched.
|
|
10101
|
+
}
|
|
10102
|
+
})
|
|
10103
|
+
}
|
|
10104
|
+
if (event.context) event.context[farmPrivateCacheControlKey] = cacheControl
|
|
10105
|
+
}
|
|
10106
|
+
` : ""}
|
|
9858
10107
|
function mergeVaryHeaders(target, source) {
|
|
9859
10108
|
const values = new Set(
|
|
9860
10109
|
[target.get('Vary'), source]
|
|
@@ -9948,11 +10197,14 @@ export default async function farmNitroEventHandler(event) {
|
|
|
9948
10197
|
const request = !srvxRequest && node?.req && node?.res
|
|
9949
10198
|
? new Request(webRequest, { signal: createFarmNodeRequestAbortSignal(node.req, node.res) })
|
|
9950
10199
|
: webRequest
|
|
9951
|
-
const response = await handler.fetch(request, {
|
|
10200
|
+
${hasNitroCacheRouteRules ? " let farmGuardedResponse = false\n" : ""} const response = await handler.fetch(request, {
|
|
9952
10201
|
waitUntil: (promise) => event.waitUntil(promise),
|
|
9953
10202
|
onResponseFinished: createResponseFinishedHook(event),
|
|
9954
10203
|
trustedLocalOrigin: resolveTrustedLocalOrigin(event, request),
|
|
9955
|
-
clientAddress: resolveFarmClientAddress(event)
|
|
10204
|
+
clientAddress: resolveFarmClientAddress(event),${hasNitroCacheRouteRules ? `
|
|
10205
|
+
onGuardedResponse: () => {
|
|
10206
|
+
farmGuardedResponse = true
|
|
10207
|
+
},` : ""}
|
|
9956
10208
|
})
|
|
9957
10209
|
|
|
9958
10210
|
// Nitro records asset compression negotiation on the event response. Merge
|
|
@@ -9963,7 +10215,15 @@ export default async function farmNitroEventHandler(event) {
|
|
|
9963
10215
|
if (farmVary) {
|
|
9964
10216
|
const nitroHeaders = event.res.headers
|
|
9965
10217
|
if (nitroHeaders.has('Vary')) mergeVaryHeaders(nitroHeaders, farmVary)
|
|
9966
|
-
}
|
|
10218
|
+
}${hasNitroCacheRouteRules ? `
|
|
10219
|
+
const farmCacheControl = response.headers.get('cache-control')
|
|
10220
|
+
if (
|
|
10221
|
+
farmGuardedResponse &&
|
|
10222
|
+
farmCacheControl &&
|
|
10223
|
+
FARM_PRIVATE_CACHE_DIRECTIVE.test(farmCacheControl)
|
|
10224
|
+
) {
|
|
10225
|
+
keepFarmPrivateCacheControl(event, farmCacheControl)
|
|
10226
|
+
}` : ""}
|
|
9967
10227
|
return ${nodeAdapterModule ? "toFarmNodeResponse(request, response)" : "response"}
|
|
9968
10228
|
}${nodeAdapterModule ? `
|
|
9969
10229
|
|
|
@@ -9984,26 +10244,38 @@ function toFarmNodeResponse(request, response) {
|
|
|
9984
10244
|
})
|
|
9985
10245
|
}` : ""}
|
|
9986
10246
|
`.trim();
|
|
9987
|
-
await
|
|
9988
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
10247
|
+
await fs4.writeFile(nitroEntryPath, nitroEntryCode);
|
|
10248
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path9.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
9989
10249
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
9990
|
-
await
|
|
9991
|
-
|
|
10250
|
+
await fs4.writeFile(
|
|
10251
|
+
path9.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
9992
10252
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
9993
10253
|
);
|
|
9994
|
-
await
|
|
10254
|
+
await fs4.writeFile(
|
|
9995
10255
|
farmNodeServerEntryPath,
|
|
9996
10256
|
createFarmNodeServerEntry({
|
|
9997
|
-
nitroEntryFile:
|
|
10257
|
+
nitroEntryFile: path9.basename(nitroEntryPath),
|
|
9998
10258
|
nodeAdapterModule,
|
|
9999
10259
|
server: config.server,
|
|
10000
10260
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node")
|
|
10001
10261
|
})
|
|
10002
10262
|
);
|
|
10003
10263
|
}
|
|
10004
|
-
const
|
|
10264
|
+
const farmBunServerEntryPath = preset === "bun" ? path9.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
|
|
10265
|
+
if (farmBunServerEntryPath) {
|
|
10266
|
+
await fs4.writeFile(
|
|
10267
|
+
farmBunServerEntryPath,
|
|
10268
|
+
createFarmBunServerEntry({
|
|
10269
|
+
nitroEntryFile: path9.basename(nitroEntryPath),
|
|
10270
|
+
bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
|
|
10271
|
+
server: config.server,
|
|
10272
|
+
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun")
|
|
10273
|
+
})
|
|
10274
|
+
);
|
|
10275
|
+
}
|
|
10276
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path9.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
10005
10277
|
if (farmNetlifyEntryPath) {
|
|
10006
|
-
await
|
|
10278
|
+
await fs4.writeFile(
|
|
10007
10279
|
farmNetlifyEntryPath,
|
|
10008
10280
|
createFarmNetlifyEntry({
|
|
10009
10281
|
nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
|
|
@@ -10035,7 +10307,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
10035
10307
|
let nitroConfig = {
|
|
10036
10308
|
preset,
|
|
10037
10309
|
...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
|
|
10310
|
+
...farmBunServerEntryPath ? { entry: farmBunServerEntryPath } : {},
|
|
10038
10311
|
...farmNetlifyEntryPath ? { entry: farmNetlifyEntryPath } : {},
|
|
10312
|
+
// The response hook that keeps a private Cache-Control under a swr or headers rule (nitro-entry).
|
|
10313
|
+
...hasNitroCacheRouteRules ? { features: { runtimeHooks: true } } : {},
|
|
10039
10314
|
rootDir: root,
|
|
10040
10315
|
// Farm registers every handler, task, and plugin explicitly. Scanning the
|
|
10041
10316
|
// project root would bundle an app's own `middleware/`, `api/`, `routes/`,
|
|
@@ -10043,7 +10318,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10043
10318
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
10044
10319
|
serverDir: false,
|
|
10045
10320
|
serverEntry: false,
|
|
10046
|
-
buildDir:
|
|
10321
|
+
buildDir: path9.join(root, distDir, ".nitro"),
|
|
10047
10322
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
10048
10323
|
compatibilityDate: "2024-12-01",
|
|
10049
10324
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -10119,7 +10394,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10119
10394
|
if (pluginManager) {
|
|
10120
10395
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
10121
10396
|
}
|
|
10122
|
-
const expectedServerDir =
|
|
10397
|
+
const expectedServerDir = path9.join(outputDir, "server");
|
|
10123
10398
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
10124
10399
|
(key) => key !== "external" && key !== "plugins"
|
|
10125
10400
|
);
|
|
@@ -10132,9 +10407,9 @@ function toFarmNodeResponse(request, response) {
|
|
|
10132
10407
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
10133
10408
|
);
|
|
10134
10409
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
10135
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 &&
|
|
10410
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && path9.resolve(nitroConfig.output?.serverDir || "") === path9.resolve(expectedServerDir) && Boolean(
|
|
10136
10411
|
nitroConfig.handlers?.some(
|
|
10137
|
-
(handler) =>
|
|
10412
|
+
(handler) => path9.resolve(handler?.handler || "") === nitroEntryPath
|
|
10138
10413
|
)
|
|
10139
10414
|
);
|
|
10140
10415
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
@@ -10195,7 +10470,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10195
10470
|
nitroInstance.routing.sync();
|
|
10196
10471
|
});
|
|
10197
10472
|
}
|
|
10198
|
-
if (farmNodeServerEntryPath || farmNetlifyEntryPath) {
|
|
10473
|
+
if (farmNodeServerEntryPath || farmBunServerEntryPath || farmNetlifyEntryPath) {
|
|
10199
10474
|
nitroInstance.hooks.hook("prerender:config", (prerendererConfig) => {
|
|
10200
10475
|
delete prerendererConfig.entry;
|
|
10201
10476
|
});
|
|
@@ -10221,14 +10496,14 @@ function toFarmNodeResponse(request, response) {
|
|
|
10221
10496
|
});
|
|
10222
10497
|
}
|
|
10223
10498
|
prerenderer.hooks.hook("compiled", async () => {
|
|
10224
|
-
const prerenderServerDir =
|
|
10499
|
+
const prerenderServerDir = path9.join(outputDir, "server");
|
|
10225
10500
|
await copyPrebuiltSSRBundle(
|
|
10226
10501
|
ssrBundle,
|
|
10227
|
-
|
|
10502
|
+
path9.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
10228
10503
|
null,
|
|
10229
|
-
|
|
10504
|
+
fs4
|
|
10230
10505
|
);
|
|
10231
|
-
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile,
|
|
10506
|
+
await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs4);
|
|
10232
10507
|
});
|
|
10233
10508
|
});
|
|
10234
10509
|
}
|
|
@@ -10259,7 +10534,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10259
10534
|
else process.env[FARM_PRERENDER_ENV] = previousPrerender;
|
|
10260
10535
|
}
|
|
10261
10536
|
}
|
|
10262
|
-
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir,
|
|
10537
|
+
const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs4, preset) : Promise.resolve(null);
|
|
10263
10538
|
const prebuiltSSRFilesPromise = canReusePrebuiltSSR ? prepareSSRBundleFiles(
|
|
10264
10539
|
ssrBundle,
|
|
10265
10540
|
shouldMinify ? { keepNames: keepServerNames, target: "node18" } : null
|
|
@@ -10272,7 +10547,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10272
10547
|
await nitroInstance.close();
|
|
10273
10548
|
if (nitroBuildResult.status === "rejected") {
|
|
10274
10549
|
if (sharpRuntimeStageResult.status === "fulfilled" && sharpRuntimeStageResult.value) {
|
|
10275
|
-
await
|
|
10550
|
+
await fs4.rm(sharpRuntimeStageResult.value.stageDir, {
|
|
10276
10551
|
recursive: true,
|
|
10277
10552
|
force: true
|
|
10278
10553
|
});
|
|
@@ -10285,20 +10560,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
10285
10560
|
if (prebuiltSSRFilesResult.status === "rejected") {
|
|
10286
10561
|
throw prebuiltSSRFilesResult.reason;
|
|
10287
10562
|
}
|
|
10288
|
-
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir,
|
|
10563
|
+
const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs4, preset) : null);
|
|
10289
10564
|
const runtimeCopyPromise = (async () => {
|
|
10290
10565
|
if (stagedSharpRuntime) {
|
|
10291
|
-
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir,
|
|
10566
|
+
await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs4);
|
|
10292
10567
|
}
|
|
10293
10568
|
if (useExternalMetadataImageRuntime) {
|
|
10294
|
-
await copyMetadataImageRuntime(root, runtimeServerOutputDir,
|
|
10569
|
+
await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs4);
|
|
10295
10570
|
}
|
|
10296
10571
|
})();
|
|
10297
10572
|
const copyResults = await Promise.allSettled([
|
|
10298
10573
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
10299
10574
|
prebuiltSSRFilesResult.value,
|
|
10300
|
-
|
|
10301
|
-
|
|
10575
|
+
path9.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
10576
|
+
fs4
|
|
10302
10577
|
) : Promise.resolve(),
|
|
10303
10578
|
runtimeCopyPromise
|
|
10304
10579
|
]);
|
|
@@ -10307,7 +10582,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10307
10582
|
);
|
|
10308
10583
|
if (failedCopy) throw failedCopy.reason;
|
|
10309
10584
|
if (canReusePrebuiltSSR) {
|
|
10310
|
-
await registerPrebuiltSSRPackageImport(
|
|
10585
|
+
await registerPrebuiltSSRPackageImport(path9.join(outputDir, "server"), ssrEntryFile, fs4);
|
|
10311
10586
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
10312
10587
|
}
|
|
10313
10588
|
if (useRolldownBuilder) {
|
|
@@ -10322,7 +10597,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
10322
10597
|
});
|
|
10323
10598
|
}
|
|
10324
10599
|
if (isVercel) {
|
|
10325
|
-
await postProcessVercelOutput(root, outputDir,
|
|
10600
|
+
await postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest);
|
|
10326
10601
|
}
|
|
10327
10602
|
logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
|
|
10328
10603
|
}
|
|
@@ -10332,11 +10607,11 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
10332
10607
|
return {
|
|
10333
10608
|
dir: outputDir,
|
|
10334
10609
|
...preset === "node-server" ? {
|
|
10335
|
-
serverDir:
|
|
10336
|
-
publicDir:
|
|
10610
|
+
serverDir: path9.join(outputDir, "server"),
|
|
10611
|
+
publicDir: path9.join(outputDir, "public")
|
|
10337
10612
|
} : isVercel ? {
|
|
10338
|
-
serverDir:
|
|
10339
|
-
publicDir:
|
|
10613
|
+
serverDir: path9.join(outputDir, "functions", "__nitro.func"),
|
|
10614
|
+
publicDir: path9.join(outputDir, "static")
|
|
10340
10615
|
} : {}
|
|
10341
10616
|
};
|
|
10342
10617
|
}
|
|
@@ -10350,24 +10625,24 @@ function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
|
|
|
10350
10625
|
);
|
|
10351
10626
|
}
|
|
10352
10627
|
__name(prepareSSRBundleFiles, "prepareSSRBundleFiles");
|
|
10353
|
-
async function writeSSRBundleFiles(files, targetDir,
|
|
10354
|
-
await
|
|
10628
|
+
async function writeSSRBundleFiles(files, targetDir, fs4) {
|
|
10629
|
+
await fs4.rm(targetDir, { recursive: true, force: true });
|
|
10355
10630
|
await Promise.all(
|
|
10356
10631
|
files.map(async ({ fileName, contents }) => {
|
|
10357
|
-
const targetPath =
|
|
10358
|
-
await
|
|
10359
|
-
await
|
|
10632
|
+
const targetPath = path9.join(targetDir, fileName);
|
|
10633
|
+
await fs4.mkdir(path9.dirname(targetPath), { recursive: true });
|
|
10634
|
+
await fs4.writeFile(targetPath, contents);
|
|
10360
10635
|
})
|
|
10361
10636
|
);
|
|
10362
10637
|
}
|
|
10363
10638
|
__name(writeSSRBundleFiles, "writeSSRBundleFiles");
|
|
10364
|
-
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions,
|
|
10365
|
-
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir,
|
|
10639
|
+
async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs4) {
|
|
10640
|
+
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs4);
|
|
10366
10641
|
}
|
|
10367
10642
|
__name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
|
|
10368
|
-
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile,
|
|
10369
|
-
const packagePath =
|
|
10370
|
-
const packageJSON = await
|
|
10643
|
+
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
|
|
10644
|
+
const packagePath = path9.join(serverDir, "package.json");
|
|
10645
|
+
const packageJSON = await fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10371
10646
|
if (error.code === "ENOENT") return { type: "module" };
|
|
10372
10647
|
throw error;
|
|
10373
10648
|
});
|
|
@@ -10377,14 +10652,14 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs3) {
|
|
|
10377
10652
|
...existingImports,
|
|
10378
10653
|
[FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
|
|
10379
10654
|
};
|
|
10380
|
-
await
|
|
10381
|
-
await
|
|
10655
|
+
await fs4.mkdir(serverDir, { recursive: true });
|
|
10656
|
+
await fs4.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
|
|
10382
10657
|
`);
|
|
10383
10658
|
}
|
|
10384
10659
|
__name(registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
|
|
10385
|
-
async function moveVercelOutputPath(src, dest,
|
|
10660
|
+
async function moveVercelOutputPath(src, dest, fs4) {
|
|
10386
10661
|
try {
|
|
10387
|
-
await
|
|
10662
|
+
await fs4.rename(src, dest);
|
|
10388
10663
|
return;
|
|
10389
10664
|
} catch (error) {
|
|
10390
10665
|
const code = error?.code;
|
|
@@ -10392,39 +10667,39 @@ async function moveVercelOutputPath(src, dest, fs3) {
|
|
|
10392
10667
|
throw error;
|
|
10393
10668
|
}
|
|
10394
10669
|
}
|
|
10395
|
-
await
|
|
10396
|
-
await
|
|
10670
|
+
await fs4.cp(src, dest, { recursive: true, force: true });
|
|
10671
|
+
await fs4.rm(src, { recursive: true, force: true });
|
|
10397
10672
|
}
|
|
10398
10673
|
__name(moveVercelOutputPath, "moveVercelOutputPath");
|
|
10399
|
-
async function postProcessVercelOutput(root, outputDir,
|
|
10400
|
-
const serverDir =
|
|
10401
|
-
const functionsDir =
|
|
10402
|
-
const nitroFuncDir =
|
|
10403
|
-
const staticDir =
|
|
10404
|
-
const publicDir =
|
|
10405
|
-
await
|
|
10406
|
-
const serverContents = await
|
|
10674
|
+
async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest) {
|
|
10675
|
+
const serverDir = path9.join(outputDir, "server");
|
|
10676
|
+
const functionsDir = path9.join(outputDir, "functions");
|
|
10677
|
+
const nitroFuncDir = path9.join(functionsDir, "__nitro.func");
|
|
10678
|
+
const staticDir = path9.join(outputDir, "static");
|
|
10679
|
+
const publicDir = path9.join(outputDir, "public");
|
|
10680
|
+
await fs4.mkdir(nitroFuncDir, { recursive: true });
|
|
10681
|
+
const serverContents = await fs4.readdir(serverDir).catch((error) => {
|
|
10407
10682
|
if (error.code === "ENOENT") return [];
|
|
10408
10683
|
throw error;
|
|
10409
10684
|
});
|
|
10410
10685
|
for (const file of serverContents) {
|
|
10411
|
-
await moveVercelOutputPath(
|
|
10686
|
+
await moveVercelOutputPath(path9.join(serverDir, file), path9.join(nitroFuncDir, file), fs4);
|
|
10412
10687
|
}
|
|
10413
|
-
if (serverContents.length > 0) await
|
|
10688
|
+
if (serverContents.length > 0) await fs4.rm(serverDir, { recursive: true, force: true });
|
|
10414
10689
|
try {
|
|
10415
|
-
await moveVercelOutputPath(publicDir, staticDir,
|
|
10690
|
+
await moveVercelOutputPath(publicDir, staticDir, fs4);
|
|
10416
10691
|
} catch (error) {
|
|
10417
10692
|
if (error?.code !== "ENOENT") throw error;
|
|
10418
10693
|
}
|
|
10419
|
-
await copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
10420
|
-
await copyPrismaClientForVercel(root, nitroFuncDir,
|
|
10421
|
-
const configPath =
|
|
10422
|
-
const configContent = await
|
|
10694
|
+
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4);
|
|
10695
|
+
await copyPrismaClientForVercel(root, nitroFuncDir, fs4);
|
|
10696
|
+
const configPath = path9.join(outputDir, "config.json");
|
|
10697
|
+
const configContent = await fs4.readFile(configPath, "utf-8");
|
|
10423
10698
|
const vercelConfig = JSON.parse(configContent);
|
|
10424
10699
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
10425
10700
|
outputDir,
|
|
10426
10701
|
routeRuntimeManifest,
|
|
10427
|
-
|
|
10702
|
+
fs4,
|
|
10428
10703
|
config.basePath
|
|
10429
10704
|
);
|
|
10430
10705
|
vercelConfig.routes = buildFarmVercelRoutes({
|
|
@@ -10439,29 +10714,29 @@ async function postProcessVercelOutput(root, outputDir, fs3, config, farmWorkflo
|
|
|
10439
10714
|
vercelConfigWithWorkflowCrons,
|
|
10440
10715
|
config.cron.jobs
|
|
10441
10716
|
);
|
|
10442
|
-
await
|
|
10717
|
+
await fs4.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
|
|
10443
10718
|
logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
|
|
10444
10719
|
}
|
|
10445
10720
|
__name(postProcessVercelOutput, "postProcessVercelOutput");
|
|
10446
|
-
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir,
|
|
10721
|
+
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
|
|
10447
10722
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
10448
10723
|
if (!docsContentDir) return;
|
|
10449
|
-
const bundledContentDir =
|
|
10724
|
+
const bundledContentDir = path9.join(nitroFuncDir, "farm-docs-content");
|
|
10450
10725
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
10451
10726
|
fallback: "now"
|
|
10452
10727
|
});
|
|
10453
|
-
await
|
|
10454
|
-
await
|
|
10455
|
-
await
|
|
10728
|
+
await fs4.rm(bundledContentDir, { recursive: true, force: true });
|
|
10729
|
+
await fs4.mkdir(path9.dirname(bundledContentDir), { recursive: true });
|
|
10730
|
+
await fs4.cp(docsContentDir, bundledContentDir, {
|
|
10456
10731
|
recursive: true,
|
|
10457
10732
|
force: true
|
|
10458
10733
|
});
|
|
10459
|
-
await
|
|
10460
|
-
|
|
10734
|
+
await fs4.writeFile(
|
|
10735
|
+
path9.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
10461
10736
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
10462
10737
|
`
|
|
10463
10738
|
);
|
|
10464
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
10739
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path9.relative(root, docsContentDir)}`);
|
|
10465
10740
|
}
|
|
10466
10741
|
__name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
|
|
10467
10742
|
function resolveServerFunctionPlatform(preset) {
|
|
@@ -10480,9 +10755,9 @@ function platformFieldAllows(field, value) {
|
|
|
10480
10755
|
return allowed.length === 0 || allowed.includes(value);
|
|
10481
10756
|
}
|
|
10482
10757
|
__name(platformFieldAllows, "platformFieldAllows");
|
|
10483
|
-
async function stageSharpRuntime(config, root, distDir,
|
|
10758
|
+
async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
10484
10759
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
10485
|
-
const projectRequire = createRequire(
|
|
10760
|
+
const projectRequire = createRequire(path9.join(root, "package.json"));
|
|
10486
10761
|
let sharpRequire = projectRequire;
|
|
10487
10762
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
10488
10763
|
try {
|
|
@@ -10492,10 +10767,10 @@ async function stageSharpRuntime(config, root, distDir, fs3, preset) {
|
|
|
10492
10767
|
}
|
|
10493
10768
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
10494
10769
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
10495
|
-
const stageRoot =
|
|
10496
|
-
await
|
|
10497
|
-
const stageDir = await
|
|
10498
|
-
const targetNodeModules =
|
|
10770
|
+
const stageRoot = path9.join(root, distDir, "tmp");
|
|
10771
|
+
await fs4.mkdir(stageRoot, { recursive: true });
|
|
10772
|
+
const stageDir = await fs4.mkdtemp(path9.join(stageRoot, "sharp-runtime-"));
|
|
10773
|
+
const targetNodeModules = path9.join(stageDir, "node_modules");
|
|
10499
10774
|
function copyPackage(packageName, parentRequire) {
|
|
10500
10775
|
const activeCopy = packageCopies.get(packageName);
|
|
10501
10776
|
if (activeCopy) return activeCopy;
|
|
@@ -10507,19 +10782,19 @@ async function stageSharpRuntime(config, root, distDir, fs3, preset) {
|
|
|
10507
10782
|
async function copyPackageOnce(packageName, parentRequire) {
|
|
10508
10783
|
const packageJsonPath = resolvePackageJson(parentRequire, packageName);
|
|
10509
10784
|
if (!packageJsonPath) return;
|
|
10510
|
-
const packageJson = JSON.parse(await
|
|
10785
|
+
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
|
|
10511
10786
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
10512
|
-
const packageDir =
|
|
10513
|
-
const targetDir =
|
|
10787
|
+
const packageDir = path9.dirname(packageJsonPath);
|
|
10788
|
+
const targetDir = path9.join(targetNodeModules, ...packageName.split("/"));
|
|
10514
10789
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
10515
|
-
await
|
|
10790
|
+
await fs4.mkdir(path9.dirname(targetDir), { recursive: true });
|
|
10516
10791
|
const packageRequire = createRequire(packageJsonPath);
|
|
10517
10792
|
const dependencies = {
|
|
10518
10793
|
...packageJson.dependencies,
|
|
10519
10794
|
...packageJson.optionalDependencies
|
|
10520
10795
|
};
|
|
10521
10796
|
await settleAllOrThrow([
|
|
10522
|
-
|
|
10797
|
+
fs4.cp(packageDir, targetDir, {
|
|
10523
10798
|
recursive: true,
|
|
10524
10799
|
force: true,
|
|
10525
10800
|
dereference: true,
|
|
@@ -10537,7 +10812,7 @@ async function stageSharpRuntime(config, root, distDir, fs3, preset) {
|
|
|
10537
10812
|
throw new Error(`Farm image optimization requires sharp. ${SHARP_INSTALL_HINT}`);
|
|
10538
10813
|
}
|
|
10539
10814
|
} catch (error) {
|
|
10540
|
-
await
|
|
10815
|
+
await fs4.rm(stageDir, { recursive: true, force: true });
|
|
10541
10816
|
throw error;
|
|
10542
10817
|
}
|
|
10543
10818
|
return {
|
|
@@ -10548,19 +10823,19 @@ async function stageSharpRuntime(config, root, distDir, fs3, preset) {
|
|
|
10548
10823
|
};
|
|
10549
10824
|
}
|
|
10550
10825
|
__name(stageSharpRuntime, "stageSharpRuntime");
|
|
10551
|
-
async function installStagedSharpRuntime(staged, nitroFuncDir,
|
|
10552
|
-
const stagedNodeModules =
|
|
10553
|
-
const targetNodeModules =
|
|
10826
|
+
async function installStagedSharpRuntime(staged, nitroFuncDir, fs4) {
|
|
10827
|
+
const stagedNodeModules = path9.join(staged.stageDir, "node_modules");
|
|
10828
|
+
const targetNodeModules = path9.join(nitroFuncDir, "node_modules");
|
|
10554
10829
|
try {
|
|
10555
|
-
await mergeStagedDirectory(stagedNodeModules, targetNodeModules,
|
|
10556
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
10830
|
+
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs4);
|
|
10831
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
|
|
10557
10832
|
functionPackage.dependencies = {
|
|
10558
10833
|
...functionPackage.dependencies,
|
|
10559
10834
|
...staged.dependencies
|
|
10560
10835
|
};
|
|
10561
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10836
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs4);
|
|
10562
10837
|
} finally {
|
|
10563
|
-
await
|
|
10838
|
+
await fs4.rm(staged.stageDir, { recursive: true, force: true });
|
|
10564
10839
|
}
|
|
10565
10840
|
logger.info(
|
|
10566
10841
|
`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${Object.keys(staged.dependencies).length} packages)`
|
|
@@ -10575,15 +10850,15 @@ async function settleAllOrThrow(operations) {
|
|
|
10575
10850
|
if (failure) throw failure.reason;
|
|
10576
10851
|
}
|
|
10577
10852
|
__name(settleAllOrThrow, "settleAllOrThrow");
|
|
10578
|
-
async function mergeStagedDirectory(sourceDir, targetDir,
|
|
10579
|
-
await
|
|
10580
|
-
const entries = await
|
|
10853
|
+
async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
10854
|
+
await fs4.mkdir(targetDir, { recursive: true });
|
|
10855
|
+
const entries = await fs4.readdir(sourceDir, { withFileTypes: true });
|
|
10581
10856
|
await settleAllOrThrow(
|
|
10582
10857
|
entries.map(async (entry) => {
|
|
10583
|
-
const sourcePath =
|
|
10584
|
-
const targetPath =
|
|
10858
|
+
const sourcePath = path9.join(sourceDir, entry.name);
|
|
10859
|
+
const targetPath = path9.join(targetDir, entry.name);
|
|
10585
10860
|
try {
|
|
10586
|
-
await
|
|
10861
|
+
await fs4.rename(sourcePath, targetPath);
|
|
10587
10862
|
return;
|
|
10588
10863
|
} catch (error) {
|
|
10589
10864
|
const code = error.code;
|
|
@@ -10592,16 +10867,16 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs3) {
|
|
|
10592
10867
|
}
|
|
10593
10868
|
}
|
|
10594
10869
|
if (entry.isDirectory()) {
|
|
10595
|
-
await mergeStagedDirectory(sourcePath, targetPath,
|
|
10596
|
-
await
|
|
10870
|
+
await mergeStagedDirectory(sourcePath, targetPath, fs4);
|
|
10871
|
+
await fs4.rm(sourcePath, { recursive: true, force: true });
|
|
10597
10872
|
return;
|
|
10598
10873
|
}
|
|
10599
|
-
await
|
|
10874
|
+
await fs4.cp(sourcePath, targetPath, {
|
|
10600
10875
|
force: true,
|
|
10601
10876
|
dereference: true,
|
|
10602
10877
|
mode: fsConstants.COPYFILE_FICLONE
|
|
10603
10878
|
});
|
|
10604
|
-
await
|
|
10879
|
+
await fs4.rm(sourcePath, { force: true });
|
|
10605
10880
|
})
|
|
10606
10881
|
);
|
|
10607
10882
|
}
|
|
@@ -10609,14 +10884,14 @@ __name(mergeStagedDirectory, "mergeStagedDirectory");
|
|
|
10609
10884
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
10610
10885
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
10611
10886
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
10612
|
-
const file = generated.modulePath ? toPosixPath(
|
|
10887
|
+
const file = generated.modulePath ? toPosixPath(path9.relative(root, generated.modulePath)) : "";
|
|
10613
10888
|
throw new Error(
|
|
10614
10889
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
10615
10890
|
);
|
|
10616
10891
|
}
|
|
10617
10892
|
__name(assertMetadataImageRuntimeInstalled, "assertMetadataImageRuntimeInstalled");
|
|
10618
10893
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
10619
|
-
const projectRequire = createRequire(
|
|
10894
|
+
const projectRequire = createRequire(path9.join(root, "package.json"));
|
|
10620
10895
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
10621
10896
|
if (packageJsonPath) return packageJsonPath;
|
|
10622
10897
|
try {
|
|
@@ -10626,40 +10901,40 @@ function resolveMetadataImageRuntimePackageJson(root) {
|
|
|
10626
10901
|
}
|
|
10627
10902
|
}
|
|
10628
10903
|
__name(resolveMetadataImageRuntimePackageJson, "resolveMetadataImageRuntimePackageJson");
|
|
10629
|
-
async function copyMetadataImageRuntime(root, nitroFuncDir,
|
|
10904
|
+
async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
|
|
10630
10905
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
10631
10906
|
if (!packageJsonPath) return;
|
|
10632
|
-
const packageJson = JSON.parse(await
|
|
10633
|
-
const packageDir =
|
|
10634
|
-
const targetDir =
|
|
10635
|
-
await
|
|
10636
|
-
await
|
|
10907
|
+
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
|
|
10908
|
+
const packageDir = path9.dirname(packageJsonPath);
|
|
10909
|
+
const targetDir = path9.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
10910
|
+
await fs4.mkdir(path9.dirname(targetDir), { recursive: true });
|
|
10911
|
+
await fs4.cp(packageDir, targetDir, {
|
|
10637
10912
|
recursive: true,
|
|
10638
10913
|
force: true,
|
|
10639
10914
|
dereference: true,
|
|
10640
10915
|
mode: fsConstants.COPYFILE_FICLONE
|
|
10641
10916
|
});
|
|
10642
|
-
const functionPackage = await readNitroOutputPackage(nitroFuncDir,
|
|
10917
|
+
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
|
|
10643
10918
|
functionPackage.dependencies = {
|
|
10644
10919
|
...functionPackage.dependencies,
|
|
10645
10920
|
"@vercel/og": String(packageJson.version || "0.11.1")
|
|
10646
10921
|
};
|
|
10647
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
10922
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs4);
|
|
10648
10923
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
10649
10924
|
}
|
|
10650
10925
|
__name(copyMetadataImageRuntime, "copyMetadataImageRuntime");
|
|
10651
|
-
async function readNitroOutputPackage(outputDir,
|
|
10652
|
-
const packagePath =
|
|
10653
|
-
return
|
|
10926
|
+
async function readNitroOutputPackage(outputDir, fs4) {
|
|
10927
|
+
const packagePath = path9.join(outputDir, "package.json");
|
|
10928
|
+
return fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10654
10929
|
if (error.code === "ENOENT") return {};
|
|
10655
10930
|
throw error;
|
|
10656
10931
|
});
|
|
10657
10932
|
}
|
|
10658
10933
|
__name(readNitroOutputPackage, "readNitroOutputPackage");
|
|
10659
|
-
async function writeNitroOutputPackage(outputDir, packageJson,
|
|
10660
|
-
await
|
|
10661
|
-
await
|
|
10662
|
-
|
|
10934
|
+
async function writeNitroOutputPackage(outputDir, packageJson, fs4) {
|
|
10935
|
+
await fs4.mkdir(outputDir, { recursive: true });
|
|
10936
|
+
await fs4.writeFile(
|
|
10937
|
+
path9.join(outputDir, "package.json"),
|
|
10663
10938
|
`${JSON.stringify(packageJson, null, 2)}
|
|
10664
10939
|
`
|
|
10665
10940
|
);
|
|
@@ -10676,9 +10951,9 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10676
10951
|
}
|
|
10677
10952
|
}
|
|
10678
10953
|
try {
|
|
10679
|
-
let directory =
|
|
10680
|
-
while (directory !==
|
|
10681
|
-
const candidate =
|
|
10954
|
+
let directory = path9.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
10955
|
+
while (directory !== path9.dirname(directory)) {
|
|
10956
|
+
const candidate = path9.join(directory, "package.json");
|
|
10682
10957
|
if (existsSync2(candidate)) {
|
|
10683
10958
|
try {
|
|
10684
10959
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
@@ -10686,52 +10961,52 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10686
10961
|
} catch {
|
|
10687
10962
|
}
|
|
10688
10963
|
}
|
|
10689
|
-
if (
|
|
10690
|
-
directory =
|
|
10964
|
+
if (path9.basename(directory) === "node_modules") break;
|
|
10965
|
+
directory = path9.dirname(directory);
|
|
10691
10966
|
}
|
|
10692
10967
|
} catch {
|
|
10693
10968
|
}
|
|
10694
10969
|
return null;
|
|
10695
10970
|
}
|
|
10696
10971
|
__name(resolvePackageJson, "resolvePackageJson");
|
|
10697
|
-
async function copyPrismaClientForVercel(root, nitroFuncDir,
|
|
10698
|
-
const projectRequire = createRequire(
|
|
10972
|
+
async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
|
|
10973
|
+
const projectRequire = createRequire(path9.join(root, "package.json"));
|
|
10699
10974
|
let prismaClientDir;
|
|
10700
10975
|
try {
|
|
10701
|
-
prismaClientDir =
|
|
10976
|
+
prismaClientDir = path9.dirname(projectRequire.resolve("@prisma/client/default.js"));
|
|
10702
10977
|
} catch {
|
|
10703
10978
|
return;
|
|
10704
10979
|
}
|
|
10705
|
-
const generatedClientDir =
|
|
10980
|
+
const generatedClientDir = path9.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
10706
10981
|
try {
|
|
10707
|
-
await
|
|
10982
|
+
await fs4.access(generatedClientDir);
|
|
10708
10983
|
} catch {
|
|
10709
10984
|
return;
|
|
10710
10985
|
}
|
|
10711
|
-
const targetNodeModules =
|
|
10712
|
-
const targetPrismaScopeDir =
|
|
10713
|
-
const targetGeneratedDir =
|
|
10714
|
-
const targetClientDir =
|
|
10715
|
-
await
|
|
10716
|
-
await
|
|
10986
|
+
const targetNodeModules = path9.join(nitroFuncDir, "node_modules");
|
|
10987
|
+
const targetPrismaScopeDir = path9.join(targetNodeModules, "@prisma");
|
|
10988
|
+
const targetGeneratedDir = path9.join(targetNodeModules, ".prisma", "client");
|
|
10989
|
+
const targetClientDir = path9.join(targetPrismaScopeDir, "client");
|
|
10990
|
+
await fs4.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
10991
|
+
await fs4.cp(prismaClientDir, targetClientDir, {
|
|
10717
10992
|
recursive: true,
|
|
10718
10993
|
force: true
|
|
10719
10994
|
});
|
|
10720
|
-
await
|
|
10995
|
+
await fs4.cp(generatedClientDir, targetGeneratedDir, {
|
|
10721
10996
|
recursive: true,
|
|
10722
10997
|
force: true
|
|
10723
10998
|
});
|
|
10724
|
-
const clientPackagePath =
|
|
10999
|
+
const clientPackagePath = path9.join(prismaClientDir, "package.json");
|
|
10725
11000
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
10726
|
-
readNitroOutputPackage(nitroFuncDir,
|
|
10727
|
-
|
|
11001
|
+
readNitroOutputPackage(nitroFuncDir, fs4),
|
|
11002
|
+
fs4.readFile(clientPackagePath, "utf-8")
|
|
10728
11003
|
]);
|
|
10729
11004
|
const clientPackage = JSON.parse(clientPackageContent);
|
|
10730
11005
|
functionPackage.dependencies = {
|
|
10731
11006
|
...functionPackage.dependencies,
|
|
10732
11007
|
"@prisma/client": clientPackage.version
|
|
10733
11008
|
};
|
|
10734
|
-
await writeNitroOutputPackage(nitroFuncDir, functionPackage,
|
|
11009
|
+
await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs4);
|
|
10735
11010
|
}
|
|
10736
11011
|
__name(copyPrismaClientForVercel, "copyPrismaClientForVercel");
|
|
10737
11012
|
|
|
@@ -10904,9 +11179,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10904
11179
|
} else {
|
|
10905
11180
|
const { build: legacyViteBuild } = await import("vite");
|
|
10906
11181
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
10907
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
11182
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path10.join(root, distDir, "client"));
|
|
10908
11183
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
10909
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
11184
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path10.join(root, distDir, "server"));
|
|
10910
11185
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
10911
11186
|
await buildNitro(
|
|
10912
11187
|
config,
|
|
@@ -11033,7 +11308,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
11033
11308
|
__name(createProjectModuleServer, "createProjectModuleServer");
|
|
11034
11309
|
async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
11035
11310
|
const { farmI18nClientBridgePlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
11036
|
-
const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
|
|
11311
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SYMK7PQ2.mjs");
|
|
11037
11312
|
const pluginManager = new PluginManager2({
|
|
11038
11313
|
config,
|
|
11039
11314
|
isDev: false,
|
|
@@ -11053,7 +11328,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
11053
11328
|
farmI18nClientBridgePlugin(),
|
|
11054
11329
|
farmServerOnlyEntriesPlugin(),
|
|
11055
11330
|
farmPlugin(config, pluginManager),
|
|
11056
|
-
farmEnvironmentFunctionsPlugin()
|
|
11331
|
+
farmEnvironmentFunctionsPlugin(config)
|
|
11057
11332
|
],
|
|
11058
11333
|
mode: "production"
|
|
11059
11334
|
});
|
|
@@ -11061,7 +11336,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
11061
11336
|
__name(buildClient2, "buildClient");
|
|
11062
11337
|
async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
11063
11338
|
const { farmI18nClientBridgePlugin, farmPlugin } = await import("./vite.mjs");
|
|
11064
|
-
const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
|
|
11339
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SYMK7PQ2.mjs");
|
|
11065
11340
|
const pluginManager = new PluginManager2({
|
|
11066
11341
|
config,
|
|
11067
11342
|
isDev: false,
|
|
@@ -11087,24 +11362,24 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
11087
11362
|
plugins: [
|
|
11088
11363
|
farmI18nClientBridgePlugin(),
|
|
11089
11364
|
farmPlugin(config, pluginManager),
|
|
11090
|
-
farmEnvironmentFunctionsPlugin()
|
|
11365
|
+
farmEnvironmentFunctionsPlugin(config)
|
|
11091
11366
|
],
|
|
11092
11367
|
mode: "production"
|
|
11093
11368
|
});
|
|
11094
11369
|
}
|
|
11095
11370
|
__name(buildSSR, "buildSSR");
|
|
11096
11371
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
11097
|
-
const appDir =
|
|
11372
|
+
const appDir = path10.join(root, srcDir, "app");
|
|
11098
11373
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
11099
|
-
const candidate =
|
|
11374
|
+
const candidate = path10.join(appDir, `page${extension}`);
|
|
11100
11375
|
if (existsSync3(candidate)) return candidate;
|
|
11101
11376
|
}
|
|
11102
|
-
return
|
|
11377
|
+
return path10.join(appDir, "page.tsx");
|
|
11103
11378
|
}
|
|
11104
11379
|
__name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
|
|
11105
11380
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
11106
11381
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
11107
|
-
import("./nitro-
|
|
11382
|
+
import("./nitro-NFG2LBRC.mjs"),
|
|
11108
11383
|
import("nitro/builder")
|
|
11109
11384
|
]);
|
|
11110
11385
|
let nitroConfig = await createNitroConfig(
|
|
@@ -11118,23 +11393,23 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11118
11393
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
11119
11394
|
}
|
|
11120
11395
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
11121
|
-
const serverOutputDir =
|
|
11122
|
-
const publicOutputDir =
|
|
11396
|
+
const serverOutputDir = path10.join(outputDir, "server");
|
|
11397
|
+
const publicOutputDir = path10.join(outputDir, "public");
|
|
11123
11398
|
const { mkdir, cp } = await import("fs/promises");
|
|
11124
11399
|
await mkdir(serverOutputDir, { recursive: true });
|
|
11125
11400
|
await mkdir(publicOutputDir, { recursive: true });
|
|
11126
|
-
const clientDir =
|
|
11401
|
+
const clientDir = path10.join(root, distDir, "client");
|
|
11127
11402
|
try {
|
|
11128
11403
|
await mkdir(publicOutputDir, { recursive: true });
|
|
11129
11404
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
11130
11405
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
11131
|
-
const manifestPath =
|
|
11132
|
-
const assetsDir =
|
|
11406
|
+
const manifestPath = path10.join(publicOutputDir, "farm-client-manifest.json");
|
|
11407
|
+
const assetsDir = path10.join(publicOutputDir, "assets");
|
|
11133
11408
|
const manifestExists = await import("fs/promises").then(
|
|
11134
|
-
(
|
|
11409
|
+
(fs4) => fs4.access(manifestPath).then(() => true).catch(() => false)
|
|
11135
11410
|
);
|
|
11136
11411
|
const assetsExist = await import("fs/promises").then(
|
|
11137
|
-
(
|
|
11412
|
+
(fs4) => fs4.access(assetsDir).then(() => true).catch(() => false)
|
|
11138
11413
|
);
|
|
11139
11414
|
if (manifestExists && assetsExist) {
|
|
11140
11415
|
logger.info("\u2705 Verified client assets are present");
|
|
@@ -11145,8 +11420,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11145
11420
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
11146
11421
|
throw error;
|
|
11147
11422
|
}
|
|
11148
|
-
const serverDir =
|
|
11149
|
-
const nitroServerDir =
|
|
11423
|
+
const serverDir = path10.join(root, distDir, "server");
|
|
11424
|
+
const nitroServerDir = path10.join(root, distDir, ".nitro", "server", "farm");
|
|
11150
11425
|
try {
|
|
11151
11426
|
await mkdir(nitroServerDir, { recursive: true });
|
|
11152
11427
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -11155,7 +11430,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11155
11430
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
11156
11431
|
}
|
|
11157
11432
|
const nitro = await createNitro(nitroConfig);
|
|
11158
|
-
const registryPath =
|
|
11433
|
+
const registryPath = path10.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
11159
11434
|
try {
|
|
11160
11435
|
const { farmRegistry } = await import(
|
|
11161
11436
|
/* @vite-ignore */
|
|
@@ -11172,7 +11447,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
11172
11447
|
}
|
|
11173
11448
|
farmRegistry.routePaths = routePaths;
|
|
11174
11449
|
try {
|
|
11175
|
-
const clientManifestPath =
|
|
11450
|
+
const clientManifestPath = path10.join(root, distDir, "client", "farm-client-manifest.json");
|
|
11176
11451
|
const { readFile } = await import("fs/promises");
|
|
11177
11452
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
11178
11453
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|