@farm.js/core 0.1.70 → 0.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-mcp-handler-6T2Z7TB6.cjs → agent-mcp-handler-KE4J3W7S.cjs} +4 -4
- package/dist/{agent-mcp-handler-CPU354QQ.mjs → agent-mcp-handler-VIT4GOSR.mjs} +3 -3
- package/dist/{agent-mcp.d-DulgFLBt.d.ts → agent-mcp.d-BO3rZXEM.d.ts} +15 -5
- package/dist/{agent-mcp.d-TAs1ES2F.d.mts → agent-mcp.d-Cwff7lcA.d.mts} +15 -5
- package/dist/agent-runtime.d.mts +3 -3
- package/dist/agent-runtime.d.ts +3 -3
- package/dist/{analyzer-QGRBLETM.mjs → analyzer-5Q75LTIL.mjs} +2 -2
- package/dist/analyzer-UJG4MIZW.cjs +16 -0
- package/dist/api/node.d.mts +5 -5
- package/dist/api/node.d.ts +5 -5
- package/dist/api/route-manager.cjs +7 -6
- package/dist/api/route-manager.d.mts +7 -7
- package/dist/api/route-manager.d.ts +7 -7
- package/dist/api/route-manager.mjs +6 -5
- package/dist/api/runtime.d.mts +4 -4
- package/dist/api/runtime.d.ts +4 -4
- package/dist/api.cjs +8 -7
- package/dist/api.d.mts +8 -8
- package/dist/api.d.ts +8 -8
- package/dist/api.mjs +7 -6
- package/dist/{app-manifest.d-C-nf3Vmm.d.ts → app-manifest.d-DwjGkYlP.d.ts} +1 -1
- package/dist/{app-manifest.d-6zXb90o6.d.mts → app-manifest.d-USD_IbFd.d.mts} +1 -1
- package/dist/app-markdown.cjs +5 -3
- package/dist/app-markdown.d.mts +5 -5
- package/dist/app-markdown.d.ts +5 -5
- package/dist/app-markdown.mjs +4 -2
- package/dist/{app.d-C2xeMIYT.d.ts → app.d-DAmF2MAk.d.ts} +52 -8
- package/dist/{app.d-DF0aundc.d.mts → app.d-fW06_h8h.d.mts} +52 -8
- package/dist/{chunk-7A3URI2F.mjs → chunk-2EVESLP3.mjs} +8 -1
- package/dist/{chunk-JRF2SKCD.mjs → chunk-3JN5M3T5.mjs} +259 -61
- package/dist/{chunk-XYVPTTUT.cjs → chunk-3WG7GJQL.cjs} +11 -6
- package/dist/{chunk-K66JILV3.cjs → chunk-5LOARKDP.cjs} +2 -2
- package/dist/{chunk-I7NUT24Z.cjs → chunk-5R4Q5FN7.cjs} +2 -2
- package/dist/{chunk-BPUVDCGG.cjs → chunk-5X6OHJEE.cjs} +15 -3
- package/dist/{chunk-RMOU3PR4.mjs → chunk-5XFKWHZD.mjs} +293 -66
- package/dist/{chunk-A2TH5MKE.mjs → chunk-645ENY7W.mjs} +3 -3
- package/dist/{chunk-NYF7A4UW.mjs → chunk-77VNYVVX.mjs} +1 -1
- package/dist/{chunk-32SYRIQ7.cjs → chunk-7QCJDYZQ.cjs} +3 -3
- package/dist/{chunk-QZHTDVH4.mjs → chunk-AUAMXI6N.mjs} +1 -1
- package/dist/{chunk-5R3JQPWD.mjs → chunk-AYVGD3PK.mjs} +1 -1
- package/dist/{chunk-IEN2EFE5.cjs → chunk-BE7AQXJB.cjs} +346 -148
- package/dist/{chunk-CCHJWJGP.mjs → chunk-BSXKZPFE.mjs} +204 -98
- package/dist/{chunk-2MR4MABG.cjs → chunk-C5AM2XDN.cjs} +54 -4
- package/dist/{chunk-M6U6E4F7.cjs → chunk-CBLRSZQL.cjs} +557 -330
- package/dist/{chunk-BBPDJGCU.cjs → chunk-CYOTNHDF.cjs} +2 -2
- package/dist/{chunk-5IJRJWJS.mjs → chunk-DGNMXL2O.mjs} +11 -1
- package/dist/{chunk-3EXCZJEN.mjs → chunk-DS7JGFW5.mjs} +13 -1
- package/dist/{chunk-EDZU7YRK.mjs → chunk-E2V7RRFL.mjs} +2 -2
- package/dist/{chunk-K7JMTAFH.cjs → chunk-E3LE6EZH.cjs} +20 -10
- package/dist/{chunk-DIHBWZDZ.cjs → chunk-ET6WW3FY.cjs} +636 -355
- package/dist/{chunk-65FPDDT4.cjs → chunk-EXN4DTVF.cjs} +2 -2
- package/dist/{chunk-K4UGCUXX.cjs → chunk-FSSONJRV.cjs} +7 -7
- package/dist/{chunk-Y2SZVIVH.cjs → chunk-GPICBTDV.cjs} +8 -1
- package/dist/{chunk-FJ5YCERM.cjs → chunk-HLMUWKAP.cjs} +466 -359
- package/dist/{chunk-A7HCBHMC.cjs → chunk-IWCYRDRQ.cjs} +3 -3
- package/dist/{chunk-R7254L3R.mjs → chunk-J5ASGNKF.mjs} +23 -0
- package/dist/{chunk-75E5FDX2.mjs → chunk-JMFTKNBA.mjs} +10 -10
- package/dist/{chunk-TLSSIYAL.mjs → chunk-KQAB5LML.mjs} +10 -3
- package/dist/{chunk-NSZY3EWG.cjs → chunk-L6E4SHUB.cjs} +31 -8
- package/dist/{chunk-OCNV4CI2.cjs → chunk-MQ4DYVFS.cjs} +26 -0
- package/dist/{chunk-4AC4PXZO.cjs → chunk-N3XO5AL5.cjs} +2 -2
- package/dist/{chunk-2AM26UGI.cjs → chunk-NLBK37HI.cjs} +5 -4
- package/dist/{chunk-R2ZHU37O.mjs → chunk-NLRAQXAA.mjs} +26 -0
- package/dist/{chunk-NA77GEIU.mjs → chunk-NV26EGMC.mjs} +51 -1
- package/dist/{chunk-LECZ5DPZ.cjs → chunk-OSEQL34Q.cjs} +2 -2
- package/dist/{chunk-3WS5AZ3R.mjs → chunk-OSMUE5ST.mjs} +8 -3
- package/dist/{chunk-JFPKARWM.cjs → chunk-PMU4U2W2.cjs} +1 -0
- package/dist/{chunk-KPMLDT3B.mjs → chunk-QUYAGU65.mjs} +581 -300
- package/dist/{chunk-N62IYXYD.mjs → chunk-RFWWXEIF.mjs} +1 -1
- package/dist/{chunk-E77IA5IF.mjs → chunk-RLFGKJQ6.mjs} +1 -1
- package/dist/{chunk-3AUINHFG.mjs → chunk-TNYC3TYP.mjs} +3 -2
- package/dist/{chunk-VG6HYT5K.cjs → chunk-TP4RAV7Y.cjs} +9 -9
- package/dist/{chunk-JFVT5ZZV.mjs → chunk-VAWDGGW3.mjs} +1 -1
- package/dist/{chunk-MU5V7XHL.mjs → chunk-VJSXPN3W.mjs} +3 -0
- package/dist/{chunk-DU4VHHPJ.mjs → chunk-VO55MMBX.mjs} +1 -1
- package/dist/{chunk-LDVJIBGN.mjs → chunk-VT25ERQK.mjs} +1 -1
- package/dist/{chunk-HAXFV2CD.mjs → chunk-WIJF3PBM.mjs} +1 -1
- package/dist/{chunk-QEWWKYDL.cjs → chunk-YCNHUIPR.cjs} +17 -10
- package/dist/{chunk-FILXOEWD.cjs → chunk-YXIQYWOK.cjs} +2 -2
- package/dist/{chunk-THG2TVDH.mjs → chunk-YZLEOMMA.mjs} +3 -3
- package/dist/{chunk-PJQ5W356.mjs → chunk-Z5ZZAGIH.mjs} +1 -0
- package/dist/{chunk-MZLJFNMH.cjs → chunk-ZDZUFD67.cjs} +1 -1
- package/dist/{chunk-Q5HMVGR5.cjs → chunk-ZFEJ2SF2.cjs} +13 -13
- package/dist/{chunk-LNVGXUL3.cjs → chunk-ZMSVKVI3.cjs} +3 -0
- package/dist/{client-component.d-DNbC4oWI.d.ts → client-component.d-9J7CkTWW.d.ts} +2 -2
- package/dist/{client-component.d-Bk5qKJM-.d.mts → client-component.d-ciHeCxr-.d.mts} +2 -2
- package/dist/{client-plugins.d-DwUqh4gp.d.ts → client-plugins.d-CUOhfapO.d.ts} +12 -8
- package/dist/{client-plugins.d-Pi9nG0W0.d.mts → client-plugins.d-JnRz5a1o.d.mts} +12 -8
- package/dist/client-plugins.d.mts +3 -3
- package/dist/client-plugins.d.ts +3 -3
- package/dist/client.cjs +1 -1
- package/dist/client.d.mts +8 -8
- package/dist/client.d.ts +8 -8
- package/dist/client.mjs +1 -1
- package/dist/config.d.mts +3 -3
- package/dist/config.d.ts +3 -3
- package/dist/desktop.d.mts +4 -4
- package/dist/desktop.d.ts +4 -4
- package/dist/{devtools-CB43AHEP.mjs → devtools-7JPQMSTQ.mjs} +4 -4
- package/dist/{devtools-L5DUNDF3.cjs → devtools-IZFUYWPG.cjs} +5 -5
- package/dist/docs.cjs +6 -6
- package/dist/docs.d.mts +4 -4
- package/dist/docs.d.ts +4 -4
- package/dist/docs.mjs +5 -5
- package/dist/environment/vite.cjs +3 -3
- package/dist/environment/vite.mjs +2 -2
- package/dist/{headers.d-CE6OWB-n.d.ts → headers.d-CqpTL_fZ.d.ts} +2 -2
- package/dist/{headers.d-DED1hHh4.d.mts → headers.d-rbbTKGaN.d.mts} +2 -2
- package/dist/i18n/client.cjs +3 -2
- package/dist/i18n/client.d.mts +2 -2
- package/dist/i18n/client.d.ts +2 -2
- package/dist/i18n/client.mjs +2 -1
- package/dist/i18n/index.cjs +3 -2
- package/dist/i18n/index.d.mts +3 -3
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/index.mjs +2 -1
- package/dist/i18n/server.cjs +6 -5
- package/dist/i18n/server.d.mts +5 -5
- package/dist/i18n/server.d.ts +5 -5
- package/dist/i18n/server.mjs +5 -4
- package/dist/index.cjs +29 -27
- package/dist/{index.d-c9UwIqDy.d.ts → index.d-CMKvzHLW.d.ts} +1 -1
- package/dist/{index.d-CbvOjJcp.d.mts → index.d-D_B2D9Il.d.mts} +1 -1
- package/dist/index.d.mts +24 -24
- package/dist/index.d.ts +24 -24
- package/dist/index.mjs +28 -26
- package/dist/integrations/orm.d.mts +3 -3
- package/dist/integrations/orm.d.ts +3 -3
- package/dist/integrations.d.mts +3 -3
- package/dist/integrations.d.ts +3 -3
- package/dist/internal/app-markdown-runtime.cjs +4 -2
- package/dist/internal/app-markdown-runtime.d.mts +13 -5
- package/dist/internal/app-markdown-runtime.d.ts +13 -5
- package/dist/internal/app-markdown-runtime.mjs +3 -1
- package/dist/internal/build-runtime.cjs +26 -26
- package/dist/internal/build-runtime.d.mts +5 -5
- package/dist/internal/build-runtime.d.ts +5 -5
- package/dist/internal/build-runtime.mjs +25 -25
- package/dist/internal/cli-runtime.cjs +9 -7
- package/dist/internal/cli-runtime.mjs +8 -6
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +2 -2
- package/dist/internal/client-runtime.d.mts +6 -6
- package/dist/internal/client-runtime.d.ts +6 -6
- package/dist/internal/client-runtime.mjs +3 -3
- package/dist/internal/compression-runtime.d.mts +3 -3
- package/dist/internal/compression-runtime.d.ts +3 -3
- package/dist/internal/config-runtime.cjs +6 -6
- package/dist/internal/config-runtime.d.mts +6 -6
- package/dist/internal/config-runtime.d.ts +6 -6
- package/dist/internal/config-runtime.mjs +5 -5
- package/dist/internal/infra-analytics-runtime.cjs +8 -8
- package/dist/internal/infra-analytics-runtime.mjs +6 -6
- package/dist/internal/native-server-fns.cjs +4 -4
- package/dist/internal/native-server-fns.mjs +3 -3
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +15 -15
- package/dist/internal/production-runtime.d.mts +41 -24
- package/dist/internal/production-runtime.d.ts +41 -24
- package/dist/internal/production-runtime.mjs +14 -14
- package/dist/internal/vercel-edge-middleware.d.mts +2 -2
- package/dist/internal/vercel-edge-middleware.d.ts +2 -2
- package/dist/markdown.d.mts +3 -3
- package/dist/markdown.d.ts +3 -3
- package/dist/middleware.cjs +3 -3
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/middleware.mjs +2 -2
- package/dist/mobile.d.mts +3 -3
- package/dist/mobile.d.ts +3 -3
- package/dist/{mount.d-DngLY7NL.d.ts → mount.d-B0XMxDRh.d.ts} +1 -1
- package/dist/{mount.d-BvWxf8ZE.d.mts → mount.d-ImEO7q8a.d.mts} +1 -1
- package/dist/{navigation-delegate.d-CMyl1h2l.d.mts → navigation-delegate.d-83Q7ksf7.d.mts} +1 -1
- package/dist/{navigation-delegate.d-zZogiDfa.d.ts → navigation-delegate.d-RRx1CSlb.d.ts} +1 -1
- package/dist/navigation.d.mts +6 -6
- package/dist/navigation.d.ts +6 -6
- package/dist/{nitro-Y3LGITW3.cjs → nitro-2LMOMIST.cjs} +2 -2
- package/dist/{nitro-NSTXT7LB.mjs → nitro-72TFIGGO.mjs} +1 -1
- package/dist/{plugin-F2O4BFTK.cjs → plugin-5PIQQVRP.cjs} +2 -2
- package/dist/{plugin-VEBRN7A3.mjs → plugin-QZT747YW.mjs} +1 -1
- package/dist/plugin.cjs +20 -20
- package/dist/plugin.d.mts +6 -6
- package/dist/plugin.d.ts +6 -6
- package/dist/plugin.mjs +19 -19
- package/dist/{production-runtime.d-B0IeWWyO.d.mts → production-runtime.d-Bcu37SCo.d.mts} +1 -1
- package/dist/{production-runtime.d-q3aHIv5Y.d.ts → production-runtime.d-qPj3XRET.d.ts} +1 -1
- package/dist/{render-plan.d-DQj2bzd2.d.ts → render-plan.d-Ds2sXJ5m.d.ts} +1 -1
- package/dist/{render-plan.d-Di1znBDW.d.mts → render-plan.d-wP8nTeRV.d.mts} +1 -1
- package/dist/renderer-client.cjs +3 -2
- package/dist/renderer-client.d.mts +6 -6
- package/dist/renderer-client.d.ts +6 -6
- package/dist/renderer-client.mjs +2 -1
- package/dist/{request.d-CJWzfDYJ.d.mts → request.d-F3h7K37m.d.mts} +1 -1
- package/dist/{request.d-C5vyoYeL.d.ts → request.d-zpSn6pu_.d.ts} +1 -1
- package/dist/request.d.mts +4 -4
- package/dist/request.d.ts +4 -4
- package/dist/{resolver.d-9iKC79CU.d.mts → resolver.d-DJgzbdsp.d.mts} +1 -1
- package/dist/{resolver.d-CY6mEa_F.d.ts → resolver.d-yaHcGCCG.d.ts} +1 -1
- package/dist/{route-rendering.d-DhsY5M2I.d.ts → route-rendering.d-BL0_AdKj.d.ts} +1 -1
- package/dist/{route-rendering.d-C-et2TZ1.d.mts → route-rendering.d-Mw0ZKG2e.d.mts} +1 -1
- package/dist/{router.d-CJB-Ntni.d.ts → router.d-BwXigemZ.d.ts} +1 -1
- package/dist/{router.d-BMDS5s5X.d.mts → router.d-NGVsU11T.d.mts} +1 -1
- package/dist/{routes.d-D3aJw1H5.d.mts → routes.d-CCccJRrp.d.mts} +1 -1
- package/dist/{routes.d-K-Qg79AA.d.ts → routes.d-b7khoRoU.d.ts} +1 -1
- package/dist/routes.d.mts +3 -3
- package/dist/routes.d.ts +3 -3
- package/dist/{routing.d-BxOZ2YWc.d.ts → routing.d-BhPgtN_S.d.ts} +2 -1
- package/dist/{routing.d-DwSUVZbF.d.mts → routing.d-D67HQmnv.d.mts} +2 -1
- package/dist/{rsc-pipeline-NJKLZ3YE.cjs → rsc-pipeline-BNXYMG4G.cjs} +6 -6
- package/dist/{rsc-pipeline-AXQJCCHI.mjs → rsc-pipeline-DHYZLWSF.mjs} +5 -5
- package/dist/{runtime-DMW6DDOI.cjs → runtime-IWOT6ZVC.cjs} +7 -7
- package/dist/{runtime-JXNEKOSE.mjs → runtime-XPYKUNL3.mjs} +5 -5
- package/dist/{runtime.d-BonodRI9.d.mts → runtime.d-BA3MzhXz.d.mts} +1 -1
- package/dist/{runtime.d-nUz0HAL4.d.mts → runtime.d-CTAXWZby.d.mts} +2 -2
- package/dist/{runtime.d-uw4123iI.d.ts → runtime.d-OBIZWpx1.d.ts} +1 -1
- package/dist/{runtime.d-B_uPfMjA.d.ts → runtime.d-PUA5qBnd.d.ts} +2 -2
- package/dist/server-plugins.d.mts +5 -5
- package/dist/server-plugins.d.ts +5 -5
- package/dist/server.cjs +40 -40
- package/dist/server.d.mts +14 -14
- package/dist/server.d.ts +14 -14
- package/dist/server.mjs +22 -22
- package/dist/{spa-router.d-rha3M95y.d.mts → spa-router.d-BG2XzE5p.d.mts} +3 -3
- package/dist/{spa-router.d-l0d9pPZj.d.ts → spa-router.d-DrYT944-.d.ts} +3 -3
- package/dist/testing.cjs +6 -5
- package/dist/testing.d.mts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/testing.mjs +6 -5
- package/dist/{types.d-wVRlLtBf.d.mts → types.d-euATAbE4.d.mts} +4 -0
- package/dist/{types.d-wVRlLtBf.d.ts → types.d-euATAbE4.d.ts} +4 -0
- package/dist/{utils.d-BzuTobEc.d.mts → utils.d-C1k9BJeD.d.mts} +1 -1
- package/dist/{utils.d-BK-PTOF8.d.ts → utils.d-DcF4wxey.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +20 -20
- package/dist/vite.d.mts +9 -7
- package/dist/vite.d.ts +9 -7
- package/dist/vite.mjs +19 -19
- package/package.json +2 -2
- package/dist/analyzer-GUIRJWZH.cjs +0 -16
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
collectFarmNativeServerFns,
|
|
28
28
|
findFarmNativeScreenFiles
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-WIJF3PBM.mjs";
|
|
30
30
|
import {
|
|
31
31
|
generateNativeMCPPluginSource
|
|
32
32
|
} from "./chunk-KQH2COEJ.mjs";
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
hasFarmDocsRuntimeAdapter,
|
|
42
42
|
listFarmDocsAdapterPages,
|
|
43
43
|
listFarmDocsPagePaths
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-VAWDGGW3.mjs";
|
|
45
45
|
import {
|
|
46
46
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
47
47
|
createFarmDocsHandler,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
} from "./chunk-OAEDVXVE.mjs";
|
|
66
66
|
import {
|
|
67
67
|
FARM_PRERENDER_ENV
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-DS7JGFW5.mjs";
|
|
69
69
|
import {
|
|
70
70
|
loadFarmDocsEngine
|
|
71
71
|
} from "./chunk-VE3FWJBO.mjs";
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
getDeployTargetForPreset,
|
|
75
75
|
hasCustomFarmRouteContext,
|
|
76
76
|
resolveDeployOutputPath
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-OSMUE5ST.mjs";
|
|
78
78
|
import {
|
|
79
79
|
resolveFarmInstrumentationFile
|
|
80
80
|
} from "./chunk-57QAQU4F.mjs";
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
resolveFarmImageServerRuntime,
|
|
111
111
|
resolveFarmNotFoundComponentPath,
|
|
112
112
|
resolveFarmRouteRootStrategy
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-5XFKWHZD.mjs";
|
|
114
114
|
import {
|
|
115
115
|
generateFarmClientPluginEntryCode,
|
|
116
116
|
hasFarmServerRuntimePlugins,
|
|
@@ -118,12 +118,12 @@ import {
|
|
|
118
118
|
} from "./chunk-I4KPA2C6.mjs";
|
|
119
119
|
import {
|
|
120
120
|
PluginManager
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-Z5ZZAGIH.mjs";
|
|
122
122
|
import {
|
|
123
123
|
generateFarmTypeArtifacts,
|
|
124
124
|
readRouteRenderingDirectiveFromFile,
|
|
125
125
|
resolveRouteRenderingConfigFromFile
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-DGNMXL2O.mjs";
|
|
127
127
|
import {
|
|
128
128
|
HOISTED_HEAD_ELEMENT,
|
|
129
129
|
appMiddlewareMayHandlePath,
|
|
@@ -136,7 +136,7 @@ import {
|
|
|
136
136
|
layoutsCanCoverSamePage,
|
|
137
137
|
routeBoundaryCoversDirectory,
|
|
138
138
|
stripRouteGroups
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-NV26EGMC.mjs";
|
|
140
140
|
import {
|
|
141
141
|
FARM_NATIVE_TREE_CONTENT_TYPE
|
|
142
142
|
} from "./chunk-LLZSYFOM.mjs";
|
|
@@ -150,15 +150,15 @@ import {
|
|
|
150
150
|
listFarmBuiltInRoutePaths,
|
|
151
151
|
resolveFarmApiCatalogInput,
|
|
152
152
|
resolveFarmAppManifestInput
|
|
153
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-645ENY7W.mjs";
|
|
154
154
|
import {
|
|
155
155
|
FARM_DEFAULT_MCP_PATH,
|
|
156
156
|
createFarmDefaultMCPServer,
|
|
157
157
|
farmConfigMountsMCP
|
|
158
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-JMFTKNBA.mjs";
|
|
159
159
|
import {
|
|
160
160
|
isFarmPreviewDeploymentEnvironment
|
|
161
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-AUAMXI6N.mjs";
|
|
162
162
|
import {
|
|
163
163
|
FARM_NATIVE_SERVER_FN_PLUGIN
|
|
164
164
|
} from "./chunk-L4RTTTVE.mjs";
|
|
@@ -176,7 +176,7 @@ import {
|
|
|
176
176
|
usePackageClientBoundaryCacheFile,
|
|
177
177
|
usesFarmServerTree,
|
|
178
178
|
withPackageClientBoundaryCache
|
|
179
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-3JN5M3T5.mjs";
|
|
180
180
|
import {
|
|
181
181
|
generateFarmDocsAdapterClientRuntime,
|
|
182
182
|
getFarmDocsAdapterConfigModule
|
|
@@ -188,7 +188,7 @@ import {
|
|
|
188
188
|
import {
|
|
189
189
|
nitroRouteRulesBelowBasePath,
|
|
190
190
|
routeRulesToNitroRouteRules
|
|
191
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-NLRAQXAA.mjs";
|
|
192
192
|
import {
|
|
193
193
|
applyFarmCspHashesToHtml,
|
|
194
194
|
createFarmCspNonce
|
|
@@ -223,7 +223,7 @@ import {
|
|
|
223
223
|
} from "./chunk-N33DLJBC.mjs";
|
|
224
224
|
import {
|
|
225
225
|
isFarmMarkdownPageFile
|
|
226
|
-
} from "./chunk-
|
|
226
|
+
} from "./chunk-J5ASGNKF.mjs";
|
|
227
227
|
import {
|
|
228
228
|
resolveFarmMdxComponentsModulePath,
|
|
229
229
|
resolveMdxConfig
|
|
@@ -255,15 +255,16 @@ import {
|
|
|
255
255
|
} from "./chunk-MMK4MZUN.mjs";
|
|
256
256
|
import {
|
|
257
257
|
APIRouteManager
|
|
258
|
-
} from "./chunk-
|
|
258
|
+
} from "./chunk-RLFGKJQ6.mjs";
|
|
259
259
|
import {
|
|
260
260
|
readFarmI18nCatalogs
|
|
261
|
-
} from "./chunk-
|
|
261
|
+
} from "./chunk-VO55MMBX.mjs";
|
|
262
262
|
import {
|
|
263
263
|
VERCEL_OG_INSTALL_HINT
|
|
264
264
|
} from "./chunk-NR63PD3P.mjs";
|
|
265
265
|
import {
|
|
266
266
|
createFarmRouteRuntimeKey,
|
|
267
|
+
farmRouteRuleMatches,
|
|
267
268
|
getFarmRouteRuntimeConfig,
|
|
268
269
|
hasFarmRouteRuntimeControls,
|
|
269
270
|
mergeFarmRouteRuntimeConfigs,
|
|
@@ -282,14 +283,14 @@ import {
|
|
|
282
283
|
} from "./chunk-2I6PUKWJ.mjs";
|
|
283
284
|
import {
|
|
284
285
|
FARM_VERSION
|
|
285
|
-
} from "./chunk-
|
|
286
|
-
import {
|
|
287
|
-
normalizeFarmTrailingSlashPathname
|
|
288
|
-
} from "./chunk-4O26BPUY.mjs";
|
|
286
|
+
} from "./chunk-77VNYVVX.mjs";
|
|
289
287
|
import {
|
|
290
288
|
getFarmPresetRuntime,
|
|
291
289
|
resolveCloudflareProcessEnvFlags
|
|
292
290
|
} from "./chunk-IWJONXPF.mjs";
|
|
291
|
+
import {
|
|
292
|
+
normalizeFarmTrailingSlashPathname
|
|
293
|
+
} from "./chunk-4O26BPUY.mjs";
|
|
293
294
|
import {
|
|
294
295
|
_runWithFarmCspNonce
|
|
295
296
|
} from "./chunk-5OFNUETM.mjs";
|
|
@@ -303,7 +304,7 @@ import {
|
|
|
303
304
|
} from "./chunk-AYP2YFVN.mjs";
|
|
304
305
|
|
|
305
306
|
// src/build/index.ts
|
|
306
|
-
import
|
|
307
|
+
import path14 from "path";
|
|
307
308
|
import { existsSync as existsSync3 } from "fs";
|
|
308
309
|
|
|
309
310
|
// src/nitro/universal-build.ts
|
|
@@ -368,7 +369,7 @@ async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
|
368
369
|
|
|
369
370
|
// src/nitro/universal-build.ts
|
|
370
371
|
import os from "os";
|
|
371
|
-
import
|
|
372
|
+
import path13 from "path";
|
|
372
373
|
import { constants as fsConstants, existsSync as existsSync2, readFileSync, realpathSync as realpathSync2, statSync } from "fs";
|
|
373
374
|
import { fileURLToPath } from "url";
|
|
374
375
|
import { builtinModules, createRequire as createRequire2 } from "module";
|
|
@@ -612,6 +613,7 @@ function collectFarmClientModulePreloads(bundle, options) {
|
|
|
612
613
|
function createFarmClientModulePreloadPlugin(options) {
|
|
613
614
|
return {
|
|
614
615
|
name: "farm-client-module-preloads",
|
|
616
|
+
enforce: "post",
|
|
615
617
|
async generateBundle(_output, bundle) {
|
|
616
618
|
await fs.mkdir(options.buildDir, { recursive: true });
|
|
617
619
|
await fs.writeFile(
|
|
@@ -686,6 +688,8 @@ function createFarmDocsModulePreloadPlugin(options) {
|
|
|
686
688
|
let runtimeModuleIds = [];
|
|
687
689
|
return {
|
|
688
690
|
name: "farm-docs-module-preloads",
|
|
691
|
+
// After Vite's CSS plugin deletes stylesheet-only chunks (see client-module-preloads.ts).
|
|
692
|
+
enforce: "post",
|
|
689
693
|
async buildStart() {
|
|
690
694
|
const resolved = await Promise.all(
|
|
691
695
|
options.modules.map((specifier) => this.resolve(specifier, options.importer))
|
|
@@ -950,12 +954,65 @@ function escapeRegExp(value) {
|
|
|
950
954
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
951
955
|
}
|
|
952
956
|
|
|
953
|
-
// src/nitro/
|
|
957
|
+
// src/nitro/immutable-assets.ts
|
|
958
|
+
import path7 from "path";
|
|
954
959
|
var FARM_IMMUTABLE_ASSET_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
960
|
+
var FARM_IMMUTABLE_ASSET_MAX_AGE = 31536e3;
|
|
961
|
+
var FARM_IMMUTABLE_ASSET_PATH_SOURCE = "^/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-(?:mobile-)?client(?:-boot)?)-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$";
|
|
962
|
+
var FARM_IMMUTABLE_ASSET_PATH = new RegExp(FARM_IMMUTABLE_ASSET_PATH_SOURCE);
|
|
963
|
+
function isFarmImmutableAssetPath(pathname) {
|
|
964
|
+
return FARM_IMMUTABLE_ASSET_PATH.test(pathname);
|
|
965
|
+
}
|
|
966
|
+
var FARM_HASHED_ASSET_DIRS = ["assets", "chunks"];
|
|
967
|
+
var LITERAL_ROUTE_PATH = /^\/[\w.~@/-]+$/;
|
|
968
|
+
function planFarmImmutableAssets(options) {
|
|
969
|
+
const cacheRulePatterns = Object.entries(options.routeRules ?? {}).filter(
|
|
970
|
+
([, rule]) => Object.keys(rule?.headers ?? {}).some((name) => name.toLowerCase() === "cache-control")
|
|
971
|
+
).map(([pattern]) => pattern);
|
|
972
|
+
const isImmutable = (file) => isFarmImmutableAssetPath(file) && !cacheRulePatterns.some((pattern) => farmRouteRuleMatches(pattern, file));
|
|
973
|
+
const routeDirs = new Set(
|
|
974
|
+
(options.routePaths ?? []).map((routePath) => routePath.split("/").filter(Boolean)[0])
|
|
975
|
+
);
|
|
976
|
+
const plan = { publicAssets: [], routeRules: {} };
|
|
977
|
+
const addRule = (file) => {
|
|
978
|
+
if (!LITERAL_ROUTE_PATH.test(file)) return;
|
|
979
|
+
plan.routeRules[file] = { headers: { "cache-control": FARM_IMMUTABLE_ASSET_CACHE_CONTROL } };
|
|
980
|
+
};
|
|
981
|
+
const dirFiles = /* @__PURE__ */ new Map();
|
|
982
|
+
for (const file of options.files) {
|
|
983
|
+
const dir = file.split("/")[1];
|
|
984
|
+
if (file.split("/").length > 2 && FARM_HASHED_ASSET_DIRS.includes(dir)) {
|
|
985
|
+
dirFiles.set(dir, [...dirFiles.get(dir) ?? [], file]);
|
|
986
|
+
} else if (isImmutable(file)) {
|
|
987
|
+
addRule(file);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
for (const [dir, files] of dirFiles) {
|
|
991
|
+
if (!routeDirs.has(dir) && files.every(isImmutable)) {
|
|
992
|
+
plan.publicAssets.push({
|
|
993
|
+
dir: path7.join(options.clientOutputDir, dir),
|
|
994
|
+
baseURL: `/${dir}`,
|
|
995
|
+
maxAge: FARM_IMMUTABLE_ASSET_MAX_AGE
|
|
996
|
+
});
|
|
997
|
+
} else {
|
|
998
|
+
for (const file of files) if (isImmutable(file)) addRule(file);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return plan;
|
|
1002
|
+
}
|
|
1003
|
+
async function listFarmClientOutputFiles(dir) {
|
|
1004
|
+
const fs4 = await import("fs/promises");
|
|
1005
|
+
const entries = await fs4.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
|
|
1006
|
+
return entries.filter((entry) => entry.isFile()).map((entry) => {
|
|
1007
|
+
const relative = path7.relative(dir, path7.join(entry.parentPath, entry.name));
|
|
1008
|
+
return `/${relative.split(path7.sep).join("/")}`;
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/nitro/vercel-assets.ts
|
|
955
1013
|
function createFarmVercelImmutableAssetRoute() {
|
|
956
|
-
const fingerprint = "-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})";
|
|
957
1014
|
return {
|
|
958
|
-
src:
|
|
1015
|
+
src: FARM_IMMUTABLE_ASSET_PATH_SOURCE,
|
|
959
1016
|
headers: {
|
|
960
1017
|
"Cache-Control": FARM_IMMUTABLE_ASSET_CACHE_CONTROL
|
|
961
1018
|
},
|
|
@@ -984,18 +1041,44 @@ function buildFarmVercelRoutes(options) {
|
|
|
984
1041
|
function escapeRegExp2(value) {
|
|
985
1042
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
986
1043
|
}
|
|
1044
|
+
var FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH = 4096;
|
|
1045
|
+
function groupFarmVercelRouteAlternatives(items, alternative) {
|
|
1046
|
+
const groups = [];
|
|
1047
|
+
let current = null;
|
|
1048
|
+
const frame = 6;
|
|
1049
|
+
for (const item of items) {
|
|
1050
|
+
const part = alternative(item);
|
|
1051
|
+
if (part.length + frame > FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH) {
|
|
1052
|
+
throw new Error(
|
|
1053
|
+
`Farm cannot route ${JSON.stringify(part.slice(0, 80))}\u2026 on Vercel: its pattern is longer than Vercel's ${FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH}-character limit for a route. Shorten the page's path.`
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
if (current && current.length + 1 + part.length > FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH) {
|
|
1057
|
+
groups.push({ src: `^(?:${current.parts.join("|")})$`, items: current.items });
|
|
1058
|
+
current = null;
|
|
1059
|
+
}
|
|
1060
|
+
if (!current) current = { parts: [], items: [], length: frame - 1 };
|
|
1061
|
+
current.parts.push(part);
|
|
1062
|
+
current.items.push(item);
|
|
1063
|
+
current.length += 1 + part.length;
|
|
1064
|
+
}
|
|
1065
|
+
if (current) groups.push({ src: `^(?:${current.parts.join("|")})$`, items: current.items });
|
|
1066
|
+
return groups;
|
|
1067
|
+
}
|
|
987
1068
|
function createFarmVercelCanonicalSlashRoutes(publicPaths) {
|
|
988
1069
|
const otherSpellings = [
|
|
989
1070
|
...new Set(
|
|
990
1071
|
publicPaths.filter((pathname) => pathname !== "/").map((pathname) => pathname.endsWith("/") ? pathname.replace(/\/+$/, "") : `${pathname}/`).filter((pathname) => pathname !== "")
|
|
991
1072
|
)
|
|
992
1073
|
];
|
|
993
|
-
|
|
994
|
-
|
|
1074
|
+
return groupFarmVercelRouteAlternatives(otherSpellings, escapeRegExp2).map((group) => ({
|
|
1075
|
+
src: group.src,
|
|
1076
|
+
dest: "/__nitro"
|
|
1077
|
+
}));
|
|
995
1078
|
}
|
|
996
1079
|
|
|
997
1080
|
// src/nitro/ssr-public-assets.ts
|
|
998
|
-
import
|
|
1081
|
+
import path8 from "path";
|
|
999
1082
|
var SERVER_FILE_URL_RE = /new\s+URL\(\s*(["'`])([^"'`\\]+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
1000
1083
|
function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
1001
1084
|
if (relativeUrl.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(relativeUrl)) return null;
|
|
@@ -1004,8 +1087,8 @@ function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
|
1004
1087
|
relativePath = decodeURI(relativePath);
|
|
1005
1088
|
} catch {
|
|
1006
1089
|
}
|
|
1007
|
-
const fileName =
|
|
1008
|
-
|
|
1090
|
+
const fileName = path8.posix.normalize(
|
|
1091
|
+
path8.posix.join(path8.posix.dirname(chunkFileName), relativePath)
|
|
1009
1092
|
);
|
|
1010
1093
|
return fileName.startsWith("../") ? null : fileName;
|
|
1011
1094
|
}
|
|
@@ -1049,7 +1132,7 @@ function collectServerOnlySSRAssets(bundle) {
|
|
|
1049
1132
|
}
|
|
1050
1133
|
}
|
|
1051
1134
|
for (const fileName of serverOnly) {
|
|
1052
|
-
const name =
|
|
1135
|
+
const name = path8.posix.basename(fileName);
|
|
1053
1136
|
if (publicReferenceSources.some((source) => source.includes(name))) {
|
|
1054
1137
|
serverOnly.delete(fileName);
|
|
1055
1138
|
}
|
|
@@ -1067,7 +1150,7 @@ function assertServerReadSSRAssetsSupported(bundle, preset, root) {
|
|
|
1067
1150
|
const output = bundle[fileName];
|
|
1068
1151
|
const original = output?.type === "asset" ? output.originalFileNames?.[0] : void 0;
|
|
1069
1152
|
if (!original) return fileName;
|
|
1070
|
-
return
|
|
1153
|
+
return path8.relative(root, path8.resolve(root, original)).split(path8.sep).join("/");
|
|
1071
1154
|
});
|
|
1072
1155
|
throw new Error(
|
|
1073
1156
|
`The "${preset}" preset cannot run server code that imports ${sources.join(", ")}. Server code reads such a file from beside the server bundle, and this edge runtime deploys no such file (Cloudflare Workers and Vercel Edge also refuse to compile WebAssembly from bytes). Load it in the browser instead, from client code with the @farm.js/wasm plugin or a "?url" import, or deploy to a Node target such as node-server, bun, vercel or netlify.`
|
|
@@ -1083,7 +1166,7 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1083
1166
|
},
|
|
1084
1167
|
transform(code, id) {
|
|
1085
1168
|
if (!code.includes("import.meta.url")) return null;
|
|
1086
|
-
const chunkFileName =
|
|
1169
|
+
const chunkFileName = path8.relative(ssrOutputDir, id.split("?", 1)[0]).split(path8.sep).join("/");
|
|
1087
1170
|
if (bundle[chunkFileName]?.type !== "chunk") return null;
|
|
1088
1171
|
let changed = false;
|
|
1089
1172
|
const transformed = replaceServerFileReferences(
|
|
@@ -1111,10 +1194,10 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
|
1111
1194
|
|
|
1112
1195
|
// src/nitro/netlify-entry.ts
|
|
1113
1196
|
import { existsSync } from "fs";
|
|
1114
|
-
import
|
|
1197
|
+
import path9 from "path";
|
|
1115
1198
|
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
1116
|
-
const entry =
|
|
1117
|
-
|
|
1199
|
+
const entry = path9.join(
|
|
1200
|
+
path9.dirname(nitroRuntimeEntry),
|
|
1118
1201
|
"..",
|
|
1119
1202
|
"presets",
|
|
1120
1203
|
"netlify",
|
|
@@ -1126,7 +1209,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
|
1126
1209
|
`[Farm.js] Could not find Nitro's Netlify function entry at ${entry}. Farm wraps it so private responses are never cached by Netlify's CDN; reinstall dependencies or report the installed Nitro version.`
|
|
1127
1210
|
);
|
|
1128
1211
|
}
|
|
1129
|
-
return entry.split(
|
|
1212
|
+
return entry.split(path9.sep).join("/");
|
|
1130
1213
|
}
|
|
1131
1214
|
function createFarmNetlifyEntry(options) {
|
|
1132
1215
|
return `
|
|
@@ -1176,7 +1259,7 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
1176
1259
|
|
|
1177
1260
|
// src/build/strip-platform-config.ts
|
|
1178
1261
|
import { realpathSync } from "fs";
|
|
1179
|
-
import
|
|
1262
|
+
import path10 from "path";
|
|
1180
1263
|
var PLATFORM_CONFIG_KEYS = /* @__PURE__ */ new Set(["desktop", "mobile"]);
|
|
1181
1264
|
var CONFIG_FACTORIES = /* @__PURE__ */ new Set(["defineConfig", "defineFarmConfig"]);
|
|
1182
1265
|
function isConfigObject(node) {
|
|
@@ -1250,11 +1333,11 @@ function realPath(file) {
|
|
|
1250
1333
|
try {
|
|
1251
1334
|
return realpathSync(file);
|
|
1252
1335
|
} catch {
|
|
1253
|
-
return
|
|
1336
|
+
return path10.resolve(file);
|
|
1254
1337
|
}
|
|
1255
1338
|
}
|
|
1256
1339
|
function farmStripPlatformConfigPlugin(configFiles) {
|
|
1257
|
-
const files = new Set(configFiles.flatMap((file) => [
|
|
1340
|
+
const files = new Set(configFiles.flatMap((file) => [path10.resolve(file), realPath(file)]));
|
|
1258
1341
|
return {
|
|
1259
1342
|
name: "farm:strip-platform-config",
|
|
1260
1343
|
// Before the TypeScript transform, so its import elision also drops imports only the
|
|
@@ -1264,9 +1347,9 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1264
1347
|
filter: { id: fileNamePattern(configFiles) },
|
|
1265
1348
|
async handler(code, id) {
|
|
1266
1349
|
const file = id.split("?", 1)[0];
|
|
1267
|
-
if (!files.has(
|
|
1350
|
+
if (!files.has(path10.resolve(file)) && !files.has(realPath(file))) return null;
|
|
1268
1351
|
const { parseAst } = await import("rolldown/parseAst");
|
|
1269
|
-
const extension =
|
|
1352
|
+
const extension = path10.extname(file).slice(1);
|
|
1270
1353
|
const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
|
|
1271
1354
|
const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
|
|
1272
1355
|
return stripped === null ? null : { code: stripped, map: null };
|
|
@@ -1277,7 +1360,7 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1277
1360
|
|
|
1278
1361
|
// src/nitro/client-sourcemaps.ts
|
|
1279
1362
|
import fs3 from "fs/promises";
|
|
1280
|
-
import
|
|
1363
|
+
import path11 from "path";
|
|
1281
1364
|
var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
|
|
1282
1365
|
function resolveFarmClientSourcemap(sourcemap) {
|
|
1283
1366
|
return sourcemap ? "hidden" : false;
|
|
@@ -1298,8 +1381,8 @@ function createFarmPrivateClientSourcemapsPlugin(options) {
|
|
|
1298
1381
|
async writeBundle() {
|
|
1299
1382
|
await fs3.rm(options.outDir, { recursive: true, force: true });
|
|
1300
1383
|
for (const [fileName, source] of maps) {
|
|
1301
|
-
const target =
|
|
1302
|
-
await fs3.mkdir(
|
|
1384
|
+
const target = path11.join(options.outDir, fileName);
|
|
1385
|
+
await fs3.mkdir(path11.dirname(target), { recursive: true });
|
|
1303
1386
|
await fs3.writeFile(target, source);
|
|
1304
1387
|
}
|
|
1305
1388
|
}
|
|
@@ -1382,7 +1465,7 @@ async function readMiddlewareFileConfig(filePath) {
|
|
|
1382
1465
|
|
|
1383
1466
|
// src/nitro/vercel-edge-middleware.ts
|
|
1384
1467
|
import { createRequire, isBuiltin } from "module";
|
|
1385
|
-
import
|
|
1468
|
+
import path12 from "path";
|
|
1386
1469
|
import { gzipSync } from "zlib";
|
|
1387
1470
|
var FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION = "_farm_middleware";
|
|
1388
1471
|
var FARM_VERCEL_EDGE_NOT_FOUND_PATH = "/__farm/not-found";
|
|
@@ -1402,18 +1485,17 @@ function toFarmVercelEdgeGuardedUrls(pathnames, basePath) {
|
|
|
1402
1485
|
...new Set(pathnames.flatMap((pathname) => [pathname, applyFarmBasePath(pathname, basePath)]))
|
|
1403
1486
|
];
|
|
1404
1487
|
}
|
|
1405
|
-
function
|
|
1488
|
+
function createFarmVercelEdgeMiddlewareRoutes(pathnames, basePath = "/") {
|
|
1406
1489
|
const publicPaths = toFarmVercelEdgeGuardedUrls(pathnames, basePath);
|
|
1407
|
-
|
|
1490
|
+
return groupFarmVercelRouteAlternatives(publicPaths, (pathname) => {
|
|
1408
1491
|
const trimmed = pathname.replace(/\/+$/, "");
|
|
1409
1492
|
return trimmed ? `${escapeRegExp3(trimmed)}(?:/|/index\\.html|\\.html)?` : "/(?:index\\.html)?";
|
|
1410
|
-
})
|
|
1411
|
-
|
|
1412
|
-
src: `^(?:${alternatives.join("|")})$`,
|
|
1493
|
+
}).map((group) => ({
|
|
1494
|
+
src: group.src,
|
|
1413
1495
|
middlewarePath: FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION,
|
|
1414
|
-
middlewareRawSrc:
|
|
1496
|
+
middlewareRawSrc: group.items,
|
|
1415
1497
|
continue: true
|
|
1416
|
-
};
|
|
1498
|
+
}));
|
|
1417
1499
|
}
|
|
1418
1500
|
function generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages) {
|
|
1419
1501
|
const imports = routes.map(
|
|
@@ -1438,21 +1520,21 @@ ${modules.join("\n")}
|
|
|
1438
1520
|
`;
|
|
1439
1521
|
}
|
|
1440
1522
|
async function resolveFarmCoreDir(root, fs4) {
|
|
1441
|
-
const runtimeEntry = createRequire(
|
|
1523
|
+
const runtimeEntry = createRequire(path12.join(root, "package.json")).resolve(
|
|
1442
1524
|
"@farm.js/core/internal/vercel-edge-middleware"
|
|
1443
1525
|
);
|
|
1444
|
-
return fs4.realpath(
|
|
1526
|
+
return fs4.realpath(path12.resolve(path12.dirname(runtimeEntry), "..", ".."));
|
|
1445
1527
|
}
|
|
1446
1528
|
function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
1447
1529
|
const streamStub = "\0farm-edge-node-stream";
|
|
1448
|
-
const corePrefix = coreDir +
|
|
1530
|
+
const corePrefix = coreDir + path12.sep;
|
|
1449
1531
|
return {
|
|
1450
1532
|
name: "farm-vercel-edge-node-modules",
|
|
1451
1533
|
resolveId(source, importer) {
|
|
1452
1534
|
if (!isBuiltin(source)) return null;
|
|
1453
1535
|
const name = source.replace(/^node:/, "").split("/")[0];
|
|
1454
1536
|
if (EDGE_NODE_MODULES.has(name)) return { id: `node:${name}`, external: true };
|
|
1455
|
-
if (name === "stream" && importer &&
|
|
1537
|
+
if (name === "stream" && importer && path12.resolve(importer).startsWith(corePrefix)) {
|
|
1456
1538
|
return streamStub;
|
|
1457
1539
|
}
|
|
1458
1540
|
unsupported.add(`${source} (imported by ${importer ?? "the entry"})`);
|
|
@@ -1466,13 +1548,13 @@ function edgeNodeModulesPlugin(coreDir, unsupported) {
|
|
|
1466
1548
|
}
|
|
1467
1549
|
async function writeFarmVercelEdgeMiddlewareFunction(options) {
|
|
1468
1550
|
const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs4 } = options;
|
|
1469
|
-
const functionDir =
|
|
1551
|
+
const functionDir = path12.join(
|
|
1470
1552
|
outputDir,
|
|
1471
1553
|
"functions",
|
|
1472
1554
|
`${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
|
|
1473
1555
|
);
|
|
1474
|
-
const entryPath =
|
|
1475
|
-
await fs4.mkdir(
|
|
1556
|
+
const entryPath = path12.join(buildDir, "vercel-edge-middleware-entry.mjs");
|
|
1557
|
+
await fs4.mkdir(path12.dirname(entryPath), { recursive: true });
|
|
1476
1558
|
await fs4.writeFile(
|
|
1477
1559
|
entryPath,
|
|
1478
1560
|
generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
|
|
@@ -1521,9 +1603,9 @@ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(",
|
|
|
1521
1603
|
}
|
|
1522
1604
|
await fs4.rm(functionDir, { recursive: true, force: true });
|
|
1523
1605
|
await fs4.mkdir(functionDir, { recursive: true });
|
|
1524
|
-
await fs4.writeFile(
|
|
1606
|
+
await fs4.writeFile(path12.join(functionDir, "index.js"), code);
|
|
1525
1607
|
await fs4.writeFile(
|
|
1526
|
-
|
|
1608
|
+
path12.join(functionDir, ".vc-config.json"),
|
|
1527
1609
|
`${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
|
|
1528
1610
|
`
|
|
1529
1611
|
);
|
|
@@ -1545,7 +1627,7 @@ async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
|
|
|
1545
1627
|
try {
|
|
1546
1628
|
return {
|
|
1547
1629
|
[clientCssHref]: await fs4.readFile(
|
|
1548
|
-
|
|
1630
|
+
path13.join(clientOutputDir, clientCssHref.slice(1)),
|
|
1549
1631
|
"utf8"
|
|
1550
1632
|
)
|
|
1551
1633
|
};
|
|
@@ -1560,18 +1642,18 @@ function preloadFarmNitroBuilder() {
|
|
|
1560
1642
|
);
|
|
1561
1643
|
}
|
|
1562
1644
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
1563
|
-
var _dirname =
|
|
1645
|
+
var _dirname = path13.dirname(_filename);
|
|
1564
1646
|
function findFarmCoreRoot(from) {
|
|
1565
|
-
let dir =
|
|
1566
|
-
while (dir !==
|
|
1567
|
-
const manifest =
|
|
1647
|
+
let dir = path13.dirname(from);
|
|
1648
|
+
while (dir !== path13.dirname(dir)) {
|
|
1649
|
+
const manifest = path13.join(dir, "package.json");
|
|
1568
1650
|
if (existsSync2(manifest)) {
|
|
1569
1651
|
try {
|
|
1570
1652
|
if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1571
1653
|
} catch {
|
|
1572
1654
|
}
|
|
1573
1655
|
}
|
|
1574
|
-
dir =
|
|
1656
|
+
dir = path13.dirname(dir);
|
|
1575
1657
|
}
|
|
1576
1658
|
return null;
|
|
1577
1659
|
}
|
|
@@ -1581,16 +1663,16 @@ function toModulePath(file) {
|
|
|
1581
1663
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1582
1664
|
}
|
|
1583
1665
|
function findInstalledPackageDir(name, from) {
|
|
1584
|
-
for (let dir = from; ; dir =
|
|
1585
|
-
const candidate =
|
|
1586
|
-
if (existsSync2(
|
|
1666
|
+
for (let dir = from; ; dir = path13.dirname(dir)) {
|
|
1667
|
+
const candidate = path13.join(dir, "node_modules", name);
|
|
1668
|
+
if (existsSync2(path13.join(candidate, "package.json"))) {
|
|
1587
1669
|
try {
|
|
1588
1670
|
return realpathSync2(candidate);
|
|
1589
1671
|
} catch {
|
|
1590
1672
|
return null;
|
|
1591
1673
|
}
|
|
1592
1674
|
}
|
|
1593
|
-
if (dir ===
|
|
1675
|
+
if (dir === path13.dirname(dir)) return null;
|
|
1594
1676
|
}
|
|
1595
1677
|
}
|
|
1596
1678
|
function collectFarmDependencyDirs(root) {
|
|
@@ -1601,7 +1683,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1601
1683
|
seen.add(dir);
|
|
1602
1684
|
let manifest;
|
|
1603
1685
|
try {
|
|
1604
|
-
manifest = JSON.parse(readFileSync(
|
|
1686
|
+
manifest = JSON.parse(readFileSync(path13.join(dir, "package.json"), "utf8"));
|
|
1605
1687
|
} catch {
|
|
1606
1688
|
return;
|
|
1607
1689
|
}
|
|
@@ -1612,7 +1694,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1612
1694
|
if (farmCoreRoot) visit(realpathSync2(farmCoreRoot));
|
|
1613
1695
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1614
1696
|
try {
|
|
1615
|
-
const manifest = JSON.parse(readFileSync(
|
|
1697
|
+
const manifest = JSON.parse(readFileSync(path13.join(root, "package.json"), "utf8"));
|
|
1616
1698
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1617
1699
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1618
1700
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1679,17 +1761,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1679
1761
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1680
1762
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1681
1763
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1682
|
-
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
1764
|
+
return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path13.sep).join("/");
|
|
1683
1765
|
}
|
|
1684
1766
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1685
1767
|
const nitroEntry = resolveNitroPackageEntry(root);
|
|
1686
|
-
const runtimeDir =
|
|
1768
|
+
const runtimeDir = path13.dirname(nitroEntry);
|
|
1687
1769
|
const nitroRequire = createRequire2(nitroEntry);
|
|
1688
1770
|
return {
|
|
1689
1771
|
...Object.fromEntries(
|
|
1690
1772
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1691
1773
|
`#nitro/runtime/${moduleName}`,
|
|
1692
|
-
|
|
1774
|
+
path13.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path13.sep).join("/")
|
|
1693
1775
|
])
|
|
1694
1776
|
),
|
|
1695
1777
|
// Farm's generated workflow and cron wrappers live under `.farm/` and
|
|
@@ -1698,7 +1780,7 @@ function resolveNitroInternalRuntimeAliases(root) {
|
|
|
1698
1780
|
...Object.fromEntries(
|
|
1699
1781
|
["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
|
|
1700
1782
|
specifier,
|
|
1701
|
-
nitroRequire.resolve(specifier).split(
|
|
1783
|
+
nitroRequire.resolve(specifier).split(path13.sep).join("/")
|
|
1702
1784
|
])
|
|
1703
1785
|
)
|
|
1704
1786
|
};
|
|
@@ -1709,7 +1791,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1709
1791
|
name: "farm-prerender-runtime-resolver",
|
|
1710
1792
|
async resolveId(id, _importer, options) {
|
|
1711
1793
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1712
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
1794
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path13.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1713
1795
|
return null;
|
|
1714
1796
|
}
|
|
1715
1797
|
if (nitroEntry === void 0) {
|
|
@@ -1732,7 +1814,7 @@ function createFarmStorageModuleRegistration(config) {
|
|
|
1732
1814
|
const modules = _collectFarmStorageModules(config.storage);
|
|
1733
1815
|
if (modules.length === 0) return "";
|
|
1734
1816
|
const root = config.root || process.cwd();
|
|
1735
|
-
const projectRequire = createRequire2(
|
|
1817
|
+
const projectRequire = createRequire2(path13.join(root, "package.json"));
|
|
1736
1818
|
let runtimeRequire = projectRequire;
|
|
1737
1819
|
try {
|
|
1738
1820
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1759,7 +1841,7 @@ ${loaders.join("\n")}
|
|
|
1759
1841
|
});` : "";
|
|
1760
1842
|
}
|
|
1761
1843
|
function resolveNitroPackageEntry(root) {
|
|
1762
|
-
const projectRequire = createRequire2(
|
|
1844
|
+
const projectRequire = createRequire2(path13.join(root, "package.json"));
|
|
1763
1845
|
let runtimeRequire = projectRequire;
|
|
1764
1846
|
try {
|
|
1765
1847
|
runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1829,7 +1911,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1829
1911
|
}
|
|
1830
1912
|
function hasReactDomEdgeServerBuild(root) {
|
|
1831
1913
|
try {
|
|
1832
|
-
createRequire2(
|
|
1914
|
+
createRequire2(path13.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1833
1915
|
return true;
|
|
1834
1916
|
} catch {
|
|
1835
1917
|
return false;
|
|
@@ -1860,9 +1942,9 @@ function isNitroRollupExternal(id) {
|
|
|
1860
1942
|
var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
|
|
1861
1943
|
var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
|
|
1862
1944
|
function isFarmCoreModule(file) {
|
|
1863
|
-
let dir =
|
|
1864
|
-
while (dir !==
|
|
1865
|
-
const manifest =
|
|
1945
|
+
let dir = path13.dirname(file.split("?", 1)[0]);
|
|
1946
|
+
while (dir !== path13.dirname(dir)) {
|
|
1947
|
+
const manifest = path13.join(dir, "package.json");
|
|
1866
1948
|
if (existsSync2(manifest)) {
|
|
1867
1949
|
try {
|
|
1868
1950
|
return JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core";
|
|
@@ -1870,7 +1952,7 @@ function isFarmCoreModule(file) {
|
|
|
1870
1952
|
return false;
|
|
1871
1953
|
}
|
|
1872
1954
|
}
|
|
1873
|
-
dir =
|
|
1955
|
+
dir = path13.dirname(dir);
|
|
1874
1956
|
}
|
|
1875
1957
|
return false;
|
|
1876
1958
|
}
|
|
@@ -1881,7 +1963,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
|
|
|
1881
1963
|
filter: { id: exactIdPattern(["@vercel/og"]) },
|
|
1882
1964
|
handler(source, importer) {
|
|
1883
1965
|
if (source !== "@vercel/og") return null;
|
|
1884
|
-
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(
|
|
1966
|
+
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path13.basename(importer.split("?", 1)[0]));
|
|
1885
1967
|
if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
|
|
1886
1968
|
return externalizeOtherImports ? { id: source, external: true } : null;
|
|
1887
1969
|
}
|
|
@@ -1902,14 +1984,14 @@ export class ImageResponse {
|
|
|
1902
1984
|
};
|
|
1903
1985
|
}
|
|
1904
1986
|
function readVercelOgManifest(file) {
|
|
1905
|
-
let dir =
|
|
1906
|
-
while (dir !==
|
|
1907
|
-
const manifestPath =
|
|
1987
|
+
let dir = path13.dirname(file.split("?", 1)[0]);
|
|
1988
|
+
while (dir !== path13.dirname(dir)) {
|
|
1989
|
+
const manifestPath = path13.join(dir, "package.json");
|
|
1908
1990
|
if (existsSync2(manifestPath)) {
|
|
1909
1991
|
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
1910
1992
|
return manifest.name === "@vercel/og" ? { dir, manifest } : null;
|
|
1911
1993
|
}
|
|
1912
|
-
dir =
|
|
1994
|
+
dir = path13.dirname(dir);
|
|
1913
1995
|
}
|
|
1914
1996
|
return null;
|
|
1915
1997
|
}
|
|
@@ -1917,7 +1999,7 @@ function resolveVercelOgConditionEntry(resolvedId, condition) {
|
|
|
1917
1999
|
const vercelOg = readVercelOgManifest(resolvedId);
|
|
1918
2000
|
const entry = vercelOg?.manifest.exports?.["."]?.[condition];
|
|
1919
2001
|
const file = typeof entry === "string" ? entry : entry?.default;
|
|
1920
|
-
return vercelOg && typeof file === "string" ?
|
|
2002
|
+
return vercelOg && typeof file === "string" ? path13.join(vercelOg.dir, file) : null;
|
|
1921
2003
|
}
|
|
1922
2004
|
function createEdgeMetadataImageRuntimePlugin({
|
|
1923
2005
|
condition,
|
|
@@ -1935,7 +2017,7 @@ function createEdgeMetadataImageRuntimePlugin({
|
|
|
1935
2017
|
if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
|
|
1936
2018
|
return null;
|
|
1937
2019
|
}
|
|
1938
|
-
const resolvedPath =
|
|
2020
|
+
const resolvedPath = path13.resolve(path13.dirname(importer.split("?", 1)[0]), source);
|
|
1939
2021
|
return { id: toPosixPath(resolvedPath), external: "absolute" };
|
|
1940
2022
|
}
|
|
1941
2023
|
};
|
|
@@ -1950,7 +2032,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
|
|
|
1950
2032
|
return null;
|
|
1951
2033
|
}
|
|
1952
2034
|
const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
|
|
1953
|
-
const encoded = readFileSync(
|
|
2035
|
+
const encoded = readFileSync(path13.resolve(path13.dirname(file), request)).toString("base64");
|
|
1954
2036
|
return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
|
|
1955
2037
|
});
|
|
1956
2038
|
if (inlined !== code) return { code: inlined, map: null };
|
|
@@ -1969,7 +2051,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
1969
2051
|
return null;
|
|
1970
2052
|
}
|
|
1971
2053
|
const requestPath = source.slice(0, -"?module".length);
|
|
1972
|
-
const resolvedPath =
|
|
2054
|
+
const resolvedPath = path13.isAbsolute(requestPath) ? requestPath : path13.resolve(path13.dirname(importer.split("?", 1)[0]), requestPath);
|
|
1973
2055
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
1974
2056
|
},
|
|
1975
2057
|
load(id) {
|
|
@@ -1994,11 +2076,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1994
2076
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
1995
2077
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
1996
2078
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
1997
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
2079
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path13.posix.normalize(path13.posix.join(path13.posix.dirname(fileName), normalizedImportId)) : null;
|
|
1998
2080
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
1999
2081
|
continue;
|
|
2000
2082
|
}
|
|
2001
|
-
if (
|
|
2083
|
+
if (path13.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
2002
2084
|
externalPackages.add(importId);
|
|
2003
2085
|
continue;
|
|
2004
2086
|
}
|
|
@@ -2010,15 +2092,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
2010
2092
|
return externalPackages;
|
|
2011
2093
|
}
|
|
2012
2094
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
2013
|
-
const resolvedNitroEntry =
|
|
2014
|
-
const resolvedSSREntry =
|
|
2095
|
+
const resolvedNitroEntry = path13.resolve(nitroEntryPath);
|
|
2096
|
+
const resolvedSSREntry = path13.resolve(ssrOutputDir, ssrEntryFile);
|
|
2015
2097
|
return {
|
|
2016
2098
|
name: "farm-externalize-prebuilt-ssr",
|
|
2017
2099
|
resolveId(source, importer) {
|
|
2018
|
-
if (!importer ||
|
|
2100
|
+
if (!importer || path13.resolve(importer) !== resolvedNitroEntry) {
|
|
2019
2101
|
return null;
|
|
2020
2102
|
}
|
|
2021
|
-
const resolvedImport =
|
|
2103
|
+
const resolvedImport = path13.resolve(path13.dirname(importer), source);
|
|
2022
2104
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
2023
2105
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
2024
2106
|
}
|
|
@@ -2151,13 +2233,13 @@ function trimSlashes(value) {
|
|
|
2151
2233
|
function resolveBuildDocsContentDir(docs, root, srcDir) {
|
|
2152
2234
|
const configuredContentDir = docs.contentDir || docs.config.contentDir;
|
|
2153
2235
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
2154
|
-
const contentDir =
|
|
2236
|
+
const contentDir = path13.isAbsolute(configuredContentDir) ? configuredContentDir : path13.join(root, configuredContentDir);
|
|
2155
2237
|
return existsSync2(contentDir) ? contentDir : null;
|
|
2156
2238
|
}
|
|
2157
2239
|
const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
|
|
2158
|
-
const appDocsDir =
|
|
2240
|
+
const appDocsDir = path13.join(root, srcDir || "src", "app", entryDir);
|
|
2159
2241
|
if (existsSync2(appDocsDir)) return appDocsDir;
|
|
2160
|
-
const rootDocsDir =
|
|
2242
|
+
const rootDocsDir = path13.join(root, entryDir);
|
|
2161
2243
|
return existsSync2(rootDocsDir) ? rootDocsDir : null;
|
|
2162
2244
|
}
|
|
2163
2245
|
function hasProjectPostcssConfig(root) {
|
|
@@ -2174,7 +2256,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
2174
2256
|
".postcssrc.mjs",
|
|
2175
2257
|
".postcssrc.ts"
|
|
2176
2258
|
];
|
|
2177
|
-
const projectRequire = createRequire2(
|
|
2259
|
+
const projectRequire = createRequire2(path13.join(root, "package.json"));
|
|
2178
2260
|
return candidates.some((file) => {
|
|
2179
2261
|
try {
|
|
2180
2262
|
projectRequire.resolve(`./${file}`);
|
|
@@ -2197,7 +2279,7 @@ async function findFarmConfigPath(root) {
|
|
|
2197
2279
|
"config.mjs"
|
|
2198
2280
|
];
|
|
2199
2281
|
for (const candidate of candidates) {
|
|
2200
|
-
const resolvedPath =
|
|
2282
|
+
const resolvedPath = path13.join(root, candidate);
|
|
2201
2283
|
try {
|
|
2202
2284
|
await fs4.access(resolvedPath);
|
|
2203
2285
|
return resolvedPath;
|
|
@@ -2234,7 +2316,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2234
2316
|
discovered.push({
|
|
2235
2317
|
path: routePath,
|
|
2236
2318
|
directory,
|
|
2237
|
-
filePath:
|
|
2319
|
+
filePath: path13.join(dir, middlewareFile.name)
|
|
2238
2320
|
});
|
|
2239
2321
|
}
|
|
2240
2322
|
for (const entry of entries) {
|
|
@@ -2242,7 +2324,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
2242
2324
|
continue;
|
|
2243
2325
|
}
|
|
2244
2326
|
await walk(
|
|
2245
|
-
|
|
2327
|
+
path13.join(dir, entry.name),
|
|
2246
2328
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
2247
2329
|
appendMiddlewareDirectory(directory, entry.name),
|
|
2248
2330
|
discovered
|
|
@@ -2272,7 +2354,6 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2272
2354
|
assertFarmDocsRuntimeSupported(config, preset);
|
|
2273
2355
|
const srcDir = config.srcDir || "src";
|
|
2274
2356
|
const distDir = config.distDir || ".farm";
|
|
2275
|
-
const deployOutputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
2276
2357
|
const lifecyclePluginManager = options.pluginManager;
|
|
2277
2358
|
const productionViteResultPromise = Promise.allSettled([
|
|
2278
2359
|
Promise.resolve(options.productionVite ?? loadFarmProductionVite())
|
|
@@ -2318,7 +2399,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2318
2399
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
2319
2400
|
const fs4 = await import("fs/promises");
|
|
2320
2401
|
const layoutRoutes = [];
|
|
2321
|
-
const appDir =
|
|
2402
|
+
const appDir = path13.join(root, srcDir, "app");
|
|
2322
2403
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
2323
2404
|
try {
|
|
2324
2405
|
const entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
@@ -2326,11 +2407,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
2326
2407
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
2327
2408
|
layoutRoutes.push({
|
|
2328
2409
|
pattern: routePrefix,
|
|
2329
|
-
modulePath:
|
|
2410
|
+
modulePath: path13.join(dir, entry.name)
|
|
2330
2411
|
});
|
|
2331
2412
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
2332
2413
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
2333
|
-
await findLayoutsForClient(
|
|
2414
|
+
await findLayoutsForClient(path13.join(dir, entry.name), childPrefix);
|
|
2334
2415
|
}
|
|
2335
2416
|
}
|
|
2336
2417
|
} catch {
|
|
@@ -2354,7 +2435,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2354
2435
|
);
|
|
2355
2436
|
}
|
|
2356
2437
|
const hydrationPlanCache = /* @__PURE__ */ new Map();
|
|
2357
|
-
const clientOutputDir =
|
|
2438
|
+
const clientOutputDir = path13.join(root, distDir, "client");
|
|
2358
2439
|
const [productionViteResult] = await productionViteResultPromise;
|
|
2359
2440
|
if (productionViteResult.status === "rejected") {
|
|
2360
2441
|
await routeRuntimeManifestResultPromise;
|
|
@@ -2479,10 +2560,10 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2479
2560
|
lifecyclePluginManager
|
|
2480
2561
|
);
|
|
2481
2562
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
2482
|
-
|
|
2563
|
+
path13.join(root, distDir),
|
|
2483
2564
|
routeRuntimeManifest
|
|
2484
2565
|
);
|
|
2485
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
2566
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path13.relative(root, runtimeManifestPath)}`);
|
|
2486
2567
|
} catch (error) {
|
|
2487
2568
|
if (lifecyclePluginManager) {
|
|
2488
2569
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -2526,8 +2607,8 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
2526
2607
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
2527
2608
|
continue;
|
|
2528
2609
|
}
|
|
2529
|
-
const filePath =
|
|
2530
|
-
await fs4.mkdir(
|
|
2610
|
+
const filePath = path13.join(outputDir, fileName);
|
|
2611
|
+
await fs4.mkdir(path13.dirname(filePath), { recursive: true });
|
|
2531
2612
|
await fs4.writeFile(filePath, output.source);
|
|
2532
2613
|
}
|
|
2533
2614
|
}
|
|
@@ -2535,15 +2616,15 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
|
2535
2616
|
const fs4 = await import("fs/promises");
|
|
2536
2617
|
await Promise.all(
|
|
2537
2618
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
2538
|
-
const targetPath =
|
|
2539
|
-
await fs4.mkdir(
|
|
2619
|
+
const targetPath = path13.join(outputDir, url.replace(/^\/+/, ""));
|
|
2620
|
+
await fs4.mkdir(path13.dirname(targetPath), { recursive: true });
|
|
2540
2621
|
await fs4.copyFile(sourcePath, targetPath);
|
|
2541
2622
|
})
|
|
2542
2623
|
);
|
|
2543
2624
|
}
|
|
2544
2625
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
2545
2626
|
const fs4 = await import("fs/promises");
|
|
2546
|
-
const fontCssPath =
|
|
2627
|
+
const fontCssPath = path13.join(outputDir, "farm-fonts.css");
|
|
2547
2628
|
let fontCss = fontCssSource;
|
|
2548
2629
|
if (fontCss === void 0) {
|
|
2549
2630
|
try {
|
|
@@ -2552,7 +2633,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
|
2552
2633
|
return;
|
|
2553
2634
|
}
|
|
2554
2635
|
}
|
|
2555
|
-
const clientCssPath =
|
|
2636
|
+
const clientCssPath = path13.join(outputDir, "farm-client.css");
|
|
2556
2637
|
let clientCss = "";
|
|
2557
2638
|
try {
|
|
2558
2639
|
clientCss = await fs4.readFile(clientCssPath, "utf8");
|
|
@@ -2578,7 +2659,7 @@ var IncompleteClientBuildOutputError = class extends Error {
|
|
|
2578
2659
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
2579
2660
|
const fs4 = await import("fs/promises");
|
|
2580
2661
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
2581
|
-
const clientEntryPath =
|
|
2662
|
+
const clientEntryPath = path13.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
2582
2663
|
let clientEntrySize = 0;
|
|
2583
2664
|
try {
|
|
2584
2665
|
const clientEntry = await fs4.stat(clientEntryPath);
|
|
@@ -2588,8 +2669,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2588
2669
|
if (clientEntrySize === 0) {
|
|
2589
2670
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
2590
2671
|
}
|
|
2591
|
-
const clientCssPath =
|
|
2592
|
-
const globalsCssPath =
|
|
2672
|
+
const clientCssPath = path13.join(outputDir, "farm-client.css");
|
|
2673
|
+
const globalsCssPath = path13.join(root, srcDir, "app", "globals.css");
|
|
2593
2674
|
let expectsCss = false;
|
|
2594
2675
|
try {
|
|
2595
2676
|
const globalsCss = await fs4.readFile(globalsCssPath, "utf8");
|
|
@@ -2610,7 +2691,7 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2610
2691
|
}
|
|
2611
2692
|
}
|
|
2612
2693
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
2613
|
-
const key = `${
|
|
2694
|
+
const key = `${path13.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${path13.resolve(modulePath)}`;
|
|
2614
2695
|
let plan = cache.get(key);
|
|
2615
2696
|
if (!plan) {
|
|
2616
2697
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -2619,10 +2700,10 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
2619
2700
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
2620
2701
|
}
|
|
2621
2702
|
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
|
|
2622
|
-
if (!mobile) await removeFarmMobileClientManifest(
|
|
2703
|
+
if (!mobile) await removeFarmMobileClientManifest(path13.dirname(outputDir));
|
|
2623
2704
|
const viteBuild = productionVite.build;
|
|
2624
2705
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2625
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
2706
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
2626
2707
|
const fs4 = await import("fs/promises");
|
|
2627
2708
|
const pluginManager = new PluginManager2({
|
|
2628
2709
|
config,
|
|
@@ -2879,10 +2960,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2879
2960
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2880
2961
|
);
|
|
2881
2962
|
const buildTarget = async (platform) => {
|
|
2882
|
-
const clientEntryRoot =
|
|
2963
|
+
const clientEntryRoot = path13.join(root, ".farm", "tmp");
|
|
2883
2964
|
await fs4.mkdir(clientEntryRoot, { recursive: true });
|
|
2884
|
-
const clientEntryDir = await fs4.mkdtemp(
|
|
2885
|
-
const clientEntryPath =
|
|
2965
|
+
const clientEntryDir = await fs4.mkdtemp(path13.join(clientEntryRoot, "client-entry-"));
|
|
2966
|
+
const clientEntryPath = path13.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2886
2967
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2887
2968
|
clientPages,
|
|
2888
2969
|
clientLayouts,
|
|
@@ -2916,11 +2997,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2916
2997
|
const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
|
|
2917
2998
|
await fs4.writeFile(clientEntryPath, clientEntry.entry);
|
|
2918
2999
|
if (clientEntry.router !== void 0) {
|
|
2919
|
-
await fs4.writeFile(
|
|
3000
|
+
await fs4.writeFile(path13.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
|
|
2920
3001
|
}
|
|
2921
3002
|
const clientInput = { [entryName]: clientEntryPath };
|
|
2922
3003
|
if (platform === "web" && canBootFarmIslandsClient(config)) {
|
|
2923
|
-
const clientBootPath =
|
|
3004
|
+
const clientBootPath = path13.join(clientEntryDir, "farm-client-boot.tsx");
|
|
2924
3005
|
await fs4.writeFile(
|
|
2925
3006
|
clientBootPath,
|
|
2926
3007
|
'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
|
|
@@ -2937,7 +3018,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2937
3018
|
if (hasScopedPostcssConfig) {
|
|
2938
3019
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
2939
3020
|
} else {
|
|
2940
|
-
const postcssConfigPath =
|
|
3021
|
+
const postcssConfigPath = path13.join(clientEntryDir, "postcss.config.cjs");
|
|
2941
3022
|
await fs4.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
2942
3023
|
postcssSearchPath = clientEntryDir;
|
|
2943
3024
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -2993,24 +3074,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2993
3074
|
plugins: [
|
|
2994
3075
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
2995
3076
|
createFarmPrivateClientSourcemapsPlugin({
|
|
2996
|
-
outDir:
|
|
2997
|
-
|
|
3077
|
+
outDir: path13.join(
|
|
3078
|
+
path13.dirname(outputDir),
|
|
2998
3079
|
platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
|
|
2999
3080
|
)
|
|
3000
3081
|
}),
|
|
3001
3082
|
// The web client's preload manifests; the mobile client records its files instead.
|
|
3002
3083
|
platform === "mobile" ? createFarmMobileClientManifestPlugin({
|
|
3003
|
-
buildDir:
|
|
3084
|
+
buildDir: path13.dirname(outputDir),
|
|
3004
3085
|
entryName
|
|
3005
3086
|
}) : createFarmClientModulePreloadPlugin({
|
|
3006
3087
|
root,
|
|
3007
|
-
buildDir:
|
|
3088
|
+
buildDir: path13.dirname(outputDir),
|
|
3008
3089
|
entryName: "farm-client"
|
|
3009
3090
|
}),
|
|
3010
3091
|
...adapterOwnsDocsRuntime && platform === "web" ? [
|
|
3011
3092
|
createFarmDocsModulePreloadPlugin({
|
|
3012
3093
|
root,
|
|
3013
|
-
buildDir:
|
|
3094
|
+
buildDir: path13.dirname(outputDir),
|
|
3014
3095
|
importer: clientEntryPath,
|
|
3015
3096
|
entryName: "farm-client",
|
|
3016
3097
|
modules: [
|
|
@@ -3114,10 +3195,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3114
3195
|
]
|
|
3115
3196
|
}
|
|
3116
3197
|
};
|
|
3117
|
-
await viteBuild(
|
|
3198
|
+
await viteBuild(
|
|
3199
|
+
mergeFarmProductionViteConfig(clientViteConfig, config.vite, { clientOutput: true })
|
|
3200
|
+
);
|
|
3118
3201
|
if (platform === "mobile") {
|
|
3119
|
-
await fs4.rm(
|
|
3120
|
-
if (!await hasFarmMobileClientEntry(
|
|
3202
|
+
await fs4.rm(path13.join(outputDir, `${entryName}.css`), { force: true });
|
|
3203
|
+
if (!await hasFarmMobileClientEntry(path13.dirname(outputDir), outputDir)) {
|
|
3121
3204
|
throw new IncompleteClientBuildOutputError(
|
|
3122
3205
|
`${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
|
|
3123
3206
|
);
|
|
@@ -3138,12 +3221,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
3138
3221
|
}
|
|
3139
3222
|
function toBakedMarkdownSourcePath(root, filePath) {
|
|
3140
3223
|
if (!filePath) return "";
|
|
3141
|
-
if (!
|
|
3142
|
-
const relative =
|
|
3143
|
-
if (!relative || relative.startsWith("..") ||
|
|
3144
|
-
return
|
|
3224
|
+
if (!path13.isAbsolute(filePath)) return filePath.split(path13.sep).join("/");
|
|
3225
|
+
const relative = path13.relative(root, filePath);
|
|
3226
|
+
if (!relative || relative.startsWith("..") || path13.isAbsolute(relative)) {
|
|
3227
|
+
return path13.basename(filePath);
|
|
3145
3228
|
}
|
|
3146
|
-
return relative.split(
|
|
3229
|
+
return relative.split(path13.sep).join("/");
|
|
3147
3230
|
}
|
|
3148
3231
|
function generateUniversalRouterStateRuntime(streamNavigations = false) {
|
|
3149
3232
|
return `
|
|
@@ -4188,7 +4271,7 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
4188
4271
|
root,
|
|
4189
4272
|
renderer.componentExtensions ?? []
|
|
4190
4273
|
);
|
|
4191
|
-
const globalsCssPath =
|
|
4274
|
+
const globalsCssPath = path13.join(root, srcDir, "app", "globals.css");
|
|
4192
4275
|
const serverStyleModules = [];
|
|
4193
4276
|
const cssImport = [
|
|
4194
4277
|
...existsSync2(globalsCssPath) ? [globalsCssPath] : [],
|
|
@@ -4368,7 +4451,8 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4368
4451
|
this.currentHistoryState = options.popState;
|
|
4369
4452
|
}
|
|
4370
4453
|
|
|
4371
|
-
|
|
4454
|
+
// Save under the page still on screen: on Back/Forward the URL already names the destination.
|
|
4455
|
+
this.saveScrollPosition(from);
|
|
4372
4456
|
const navigation = this.startNavigation(from, url, action);
|
|
4373
4457
|
let clientNavigation;
|
|
4374
4458
|
try {
|
|
@@ -4628,7 +4712,8 @@ async function createFarmServerTreePageElement(source, pathname) {
|
|
|
4628
4712
|
return await createFarmServerTreeElement(React, source, {
|
|
4629
4713
|
load: loadFarmIsolatedBoundary,
|
|
4630
4714
|
ServerHtml: FarmServerPage,
|
|
4631
|
-
key:
|
|
4715
|
+
// No key: the next page of the same layout updates this one in place, as React Server
|
|
4716
|
+
// Components do, instead of unmounting it and building every node again.
|
|
4632
4717
|
});
|
|
4633
4718
|
} catch (error) {
|
|
4634
4719
|
console.warn("[Farm.js] Could not rebuild the server tree of " + pathname + "; its server HTML was kept.", error);
|
|
@@ -5577,7 +5662,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5577
5662
|
// A route transition invalidates any trigger waiting on the previous DOM boundary.
|
|
5578
5663
|
cancelPendingPageHydration();
|
|
5579
5664
|
this.stopNavigationStream();
|
|
5580
|
-
|
|
5665
|
+
// Save under the page still on screen: on Back/Forward the URL already names the destination.
|
|
5666
|
+
this.saveScrollPosition(from);
|
|
5581
5667
|
const navigation = this.startNavigation(from, url, action);
|
|
5582
5668
|
// A refresh keeps the islands still on the page (islands mode).
|
|
5583
5669
|
navigation.refresh = options.refresh === true;
|
|
@@ -6024,7 +6110,7 @@ void hydrate();
|
|
|
6024
6110
|
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
|
|
6025
6111
|
const viteBuild = productionVite.build;
|
|
6026
6112
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
6027
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
6113
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
6028
6114
|
const fs4 = await import("fs/promises");
|
|
6029
6115
|
const pluginManager = new PluginManager2({
|
|
6030
6116
|
config,
|
|
@@ -6040,9 +6126,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6040
6126
|
buildLifetime: rendererBuildLifetime
|
|
6041
6127
|
});
|
|
6042
6128
|
if (!hasScopedPostcssConfig) {
|
|
6043
|
-
postcssConfigDir = await fs4.mkdtemp(
|
|
6129
|
+
postcssConfigDir = await fs4.mkdtemp(path13.join(os.tmpdir(), "farm-postcss-"));
|
|
6044
6130
|
await fs4.writeFile(
|
|
6045
|
-
|
|
6131
|
+
path13.join(postcssConfigDir, "postcss.config.cjs"),
|
|
6046
6132
|
"module.exports = { plugins: [] };\n"
|
|
6047
6133
|
);
|
|
6048
6134
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -6144,13 +6230,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6144
6230
|
specRoute: config.openapi.specRoute || null
|
|
6145
6231
|
};
|
|
6146
6232
|
}
|
|
6147
|
-
const
|
|
6148
|
-
|
|
6149
|
-
discoveredMiddlewareRoutes.map(async (route) => ({
|
|
6233
|
+
const middlewareRoutes = await Promise.all(
|
|
6234
|
+
(await discoverMiddlewareRoutes(appDirs)).map(async (route) => ({
|
|
6150
6235
|
...route,
|
|
6151
6236
|
config: await readMiddlewareFileConfig(route.filePath)
|
|
6152
6237
|
}))
|
|
6153
|
-
)
|
|
6238
|
+
);
|
|
6154
6239
|
const instrumentationPath = resolveFarmInstrumentationFile(root, config.srcDir || "src");
|
|
6155
6240
|
const notFoundPath = resolveFarmNotFoundComponentPath(config, appDirs);
|
|
6156
6241
|
if (notFoundPath) logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
|
|
@@ -6465,7 +6550,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
6465
6550
|
}
|
|
6466
6551
|
function readFarmAppPackageIdentity(root) {
|
|
6467
6552
|
try {
|
|
6468
|
-
return JSON.parse(readFileSync(
|
|
6553
|
+
return JSON.parse(readFileSync(path13.join(root, "package.json"), "utf8"));
|
|
6469
6554
|
} catch {
|
|
6470
6555
|
return {};
|
|
6471
6556
|
}
|
|
@@ -7075,10 +7160,13 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
7075
7160
|
orderedPageRoutes.forEach((route, index) => {
|
|
7076
7161
|
const varName = `pageRoute${index}`;
|
|
7077
7162
|
if (isFarmMarkdownPageFile(route.modulePath)) {
|
|
7163
|
+
const renderingDirective2 = readRouteRenderingDirectiveFromFile(route.modulePath);
|
|
7164
|
+
const markdownServerTree = pageHydrationPlanOptions.serverOwners && usesFarmServerTree(pageHydrationPlans.get(route.modulePath));
|
|
7078
7165
|
pageRegistrations.push(`
|
|
7079
7166
|
{
|
|
7080
7167
|
pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
|
|
7081
|
-
directory: ${JSON.stringify(route.directory)},` : ""}
|
|
7168
|
+
directory: ${JSON.stringify(route.directory)},` : ""}${renderingDirective2 ? `
|
|
7169
|
+
rendering: ${JSON.stringify(renderingDirective2)},` : ""}${markdownServerTree ? "\n serverTree: true," : ""}
|
|
7082
7170
|
module: createFarmMarkdownRouteModule({
|
|
7083
7171
|
source: ${JSON.stringify(route.source ?? "")},
|
|
7084
7172
|
filePath: ${JSON.stringify(toBakedMarkdownSourcePath(config.root, route.modulePath))},
|
|
@@ -7453,7 +7541,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
7453
7541
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
7454
7542
|
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;";
|
|
7455
7543
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
7456
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
7544
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path13.isAbsolute(config.mdx.components) ? config.mdx.components : path13.join(config.root, config.mdx.components) : null;
|
|
7457
7545
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
7458
7546
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
7459
7547
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -7992,7 +8080,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
7992
8080
|
|
|
7993
8081
|
// API routes bundled at build time
|
|
7994
8082
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
7995
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
8083
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path15, methods }) => ({ path: path15, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
7996
8084
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
7997
8085
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
7998
8086
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -8529,12 +8617,98 @@ async function renderFarmElement(ReactDOMServer, element, routeKey, flushToken =
|
|
|
8529
8617
|
return { html, head: "", shellHtml: html, streamErrors };
|
|
8530
8618
|
}
|
|
8531
8619
|
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8620
|
+
// The not-found and error documents go out whole, with their status, so they never stream.
|
|
8621
|
+
// renderToString renders a tree that does not suspend in one synchronous pass, but throws "A
|
|
8622
|
+
// component suspended while responding to synchronous input" when a lazy component or a use()
|
|
8623
|
+
// read suspends outside a Suspense boundary, and leaves a boundary that suspends inside one to
|
|
8624
|
+
// the client (<!--$!-->). Such a document renders with the streaming renderer instead, which
|
|
8625
|
+
// sends nothing until every boundary is done, so the output is the resolved markup without
|
|
8626
|
+
// fallbacks or reveal scripts. A document that suspended once keeps that renderer for the rest
|
|
8627
|
+
// of this server process, as a page route that suspends keeps streaming. As for pages, a
|
|
8628
|
+
// response with a CSP nonce or a posted form state renders with the stream, which takes them.
|
|
8629
|
+
// Renderers other than React wait for their own async content in renderToString.
|
|
8630
|
+
const farmSuspendingDocuments = new Set();
|
|
8631
|
+
|
|
8632
|
+
async function renderFarmCompleteDocument(ReactDOMServer, element, documentKey) {
|
|
8633
|
+
if (!farmReactSyncRender || !canRenderFarmElementWhenAllReady(ReactDOMServer)) {
|
|
8634
|
+
return await ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
|
|
8635
|
+
}
|
|
8636
|
+
if (!farmSuspendingDocuments.has(documentKey) &&
|
|
8637
|
+
!_resolveCurrentCspNonce() &&
|
|
8638
|
+
farmFormState() === undefined) {
|
|
8639
|
+
let html;
|
|
8640
|
+
try {
|
|
8641
|
+
html = ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
|
|
8642
|
+
} catch {
|
|
8643
|
+
// A real render error fails the streaming render the same way.
|
|
8644
|
+
}
|
|
8645
|
+
if (typeof html === "string" && !html.includes("<!--$!-->")) return html;
|
|
8646
|
+
farmSuspendingDocuments.add(documentKey);
|
|
8647
|
+
}
|
|
8648
|
+
return await renderFarmElementWhenAllReady(ReactDOMServer, element);
|
|
8649
|
+
}
|
|
8650
|
+
|
|
8651
|
+
function canRenderFarmElementWhenAllReady(ReactDOMServer) {
|
|
8652
|
+
return (farmRendererStreamingCapabilities.web &&
|
|
8653
|
+
typeof ReactDOMServer.renderToReadableStream === "function") ||
|
|
8654
|
+
(farmRendererStreamingCapabilities.node &&
|
|
8655
|
+
typeof ReactDOMServer.renderToPipeableStream === "function");
|
|
8656
|
+
}
|
|
8657
|
+
|
|
8658
|
+
async function renderFarmElementWhenAllReady(ReactDOMServer, element) {
|
|
8659
|
+
const onError = function(error) {
|
|
8660
|
+
// After the shell, a failed boundary is rendered by the client, as on a page.
|
|
8661
|
+
if (isFarmRedirectError(error) || isFarmNotFoundError(error)) return;
|
|
8662
|
+
console.error("[Farm SSR stream]", error);
|
|
8663
|
+
};
|
|
8664
|
+
// Completed boundaries larger than this would stream behind their fallback: keep them inline.
|
|
8665
|
+
const progressiveChunkSize = Number.MAX_SAFE_INTEGER;
|
|
8666
|
+
if (farmRendererStreamingCapabilities.web &&
|
|
8667
|
+
typeof ReactDOMServer.renderToReadableStream === "function") {
|
|
8668
|
+
const stream = await ReactDOMServer.renderToReadableStream(element, {
|
|
8669
|
+
nonce: _resolveCurrentCspNonce(),
|
|
8670
|
+
formState: farmFormState(),
|
|
8671
|
+
progressiveChunkSize,
|
|
8672
|
+
onError,
|
|
8673
|
+
});
|
|
8674
|
+
await stream.allReady;
|
|
8675
|
+
return await new Response(stream).text();
|
|
8676
|
+
}
|
|
8677
|
+
return await new Promise(function(resolve, reject) {
|
|
8678
|
+
const chunks = [];
|
|
8679
|
+
const decoder = new TextDecoder();
|
|
8680
|
+
const destination = {
|
|
8681
|
+
write(chunk) {
|
|
8682
|
+
chunks.push(typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }));
|
|
8683
|
+
return true;
|
|
8684
|
+
},
|
|
8685
|
+
flush() {},
|
|
8686
|
+
end() {
|
|
8687
|
+
chunks.push(decoder.decode());
|
|
8688
|
+
resolve(chunks.join(""));
|
|
8689
|
+
},
|
|
8690
|
+
on() {
|
|
8691
|
+
return destination;
|
|
8692
|
+
},
|
|
8693
|
+
destroy(error) {
|
|
8694
|
+
reject(error || new Error("React server render stream was destroyed"));
|
|
8695
|
+
},
|
|
8696
|
+
};
|
|
8697
|
+
const pipeableStream = ReactDOMServer.renderToPipeableStream(element, {
|
|
8698
|
+
nonce: _resolveCurrentCspNonce(),
|
|
8699
|
+
formState: farmFormState(),
|
|
8700
|
+
progressiveChunkSize,
|
|
8701
|
+
onAllReady() {
|
|
8702
|
+
try {
|
|
8703
|
+
pipeableStream.pipe(destination);
|
|
8704
|
+
} catch (error) {
|
|
8705
|
+
reject(error);
|
|
8706
|
+
}
|
|
8707
|
+
},
|
|
8708
|
+
onShellError: reject,
|
|
8709
|
+
onError,
|
|
8710
|
+
});
|
|
8711
|
+
});
|
|
8538
8712
|
}
|
|
8539
8713
|
|
|
8540
8714
|
// Most pages render without suspending. React's renderToString renders them in
|
|
@@ -8716,6 +8890,50 @@ function opensFarmFullDocument(markup) {
|
|
|
8716
8890
|
return /^<!doctype/i.test(inner) || /^<html[\\s>]/i.test(inner);
|
|
8717
8891
|
}
|
|
8718
8892
|
|
|
8893
|
+
// The head elements a component renders (<meta>, <title>, preloads), which React writes ahead of
|
|
8894
|
+
// a render whose root is not <html>, split off for the document's head. A full document keeps
|
|
8895
|
+
// them: its own head takes them. Matches the dev renderer's takeFarmHoistedHead.
|
|
8896
|
+
function takeFarmHoistedHead(markup) {
|
|
8897
|
+
if (opensFarmFullDocument(markup)) return { head: "", body: markup };
|
|
8898
|
+
const hoistable = /${HOISTED_HEAD_ELEMENT.source}/i;
|
|
8899
|
+
let head = "";
|
|
8900
|
+
let body = markup;
|
|
8901
|
+
let match;
|
|
8902
|
+
while ((match = hoistable.exec(body.replace(/^\\s+/, "")))) {
|
|
8903
|
+
head += match[0];
|
|
8904
|
+
body = body.replace(/^\\s+/, "").slice(match[0].length);
|
|
8905
|
+
}
|
|
8906
|
+
return { head: head, body: body };
|
|
8907
|
+
}
|
|
8908
|
+
|
|
8909
|
+
// A rendered page with the head elements React wrote first moved to its head field, for Farm's shell to
|
|
8910
|
+
// put in the document's head. A streamed page's first chunk is its shellHtml: those bytes are
|
|
8911
|
+
// dropped from the stream.
|
|
8912
|
+
function takeFarmRenderedHead(rendered) {
|
|
8913
|
+
if (rendered.head) return rendered;
|
|
8914
|
+
if (rendered.html !== undefined) {
|
|
8915
|
+
const split = takeFarmHoistedHead(rendered.html);
|
|
8916
|
+
if (!split.head) return rendered;
|
|
8917
|
+
return Object.assign({}, rendered, { html: split.body, shellHtml: split.body, head: split.head });
|
|
8918
|
+
}
|
|
8919
|
+
const shell = rendered.shellHtml || "";
|
|
8920
|
+
const split = takeFarmHoistedHead(shell);
|
|
8921
|
+
if (!split.head) return rendered;
|
|
8922
|
+
let left = new TextEncoder().encode(shell.slice(0, shell.length - split.body.length)).byteLength;
|
|
8923
|
+
const stream = rendered.stream.pipeThrough(new TransformStream({
|
|
8924
|
+
transform(chunk, controller) {
|
|
8925
|
+
if (left > 0) {
|
|
8926
|
+
const dropped = Math.min(left, chunk.byteLength);
|
|
8927
|
+
left -= dropped;
|
|
8928
|
+
chunk = chunk.subarray(dropped);
|
|
8929
|
+
if (chunk.byteLength === 0) return;
|
|
8930
|
+
}
|
|
8931
|
+
controller.enqueue(chunk);
|
|
8932
|
+
},
|
|
8933
|
+
}));
|
|
8934
|
+
return Object.assign({}, rendered, { stream: stream, shellHtml: split.body, head: split.head });
|
|
8935
|
+
}
|
|
8936
|
+
|
|
8719
8937
|
function extractFarmFullDocument(markup) {
|
|
8720
8938
|
if (!opensFarmFullDocument(markup)) return null;
|
|
8721
8939
|
const hoisted = peelFarmDocumentPrefix(markup).hoisted;
|
|
@@ -8831,8 +9049,9 @@ const farmClientEntryPreloadTags = farmClientModulePreloads
|
|
|
8831
9049
|
? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
|
|
8832
9050
|
: "";
|
|
8833
9051
|
// The client modules a document's markup loads: its islands' boundaries and the
|
|
8834
|
-
// client references of its server tree.
|
|
8835
|
-
|
|
9052
|
+
// client references of its server tree. An island with a deferred strategy loads its
|
|
9053
|
+
// module on its own trigger, so it is not preloaded.
|
|
9054
|
+
const FARM_CLIENT_MODULE_REFERENCE_PATTERN = /<f-island src="([^"]+)"([^>]*)>|"r":"(\\/[^"]+)"/g;
|
|
8836
9055
|
|
|
8837
9056
|
function renderFarmClientModulePreload(index) {
|
|
8838
9057
|
return '\\n <link rel="modulepreload" href="/' +
|
|
@@ -8860,7 +9079,10 @@ function renderFarmClientModulePreloads(markup, pageModule) {
|
|
|
8860
9079
|
};
|
|
8861
9080
|
add(pageModule);
|
|
8862
9081
|
if (typeof markup === "string") {
|
|
8863
|
-
for (const match of markup.matchAll(FARM_CLIENT_MODULE_REFERENCE_PATTERN))
|
|
9082
|
+
for (const match of markup.matchAll(FARM_CLIENT_MODULE_REFERENCE_PATTERN)) {
|
|
9083
|
+
if (match[1] && FARM_DEFERRED_ISLAND_STRATEGY.test(match[2])) continue;
|
|
9084
|
+
add(match[1] || match[3]);
|
|
9085
|
+
}
|
|
8864
9086
|
}
|
|
8865
9087
|
return tags;
|
|
8866
9088
|
}
|
|
@@ -9263,16 +9485,20 @@ function getFarmDefaultMCPServer() {
|
|
|
9263
9485
|
}
|
|
9264
9486
|
async function handleFarmDefaultMCP(request) {
|
|
9265
9487
|
const origin = new URL(request.url).origin;
|
|
9488
|
+
// Pages are linked on metadataBase, as sitemap.xml and llms.txt link them.
|
|
9489
|
+
const metadataBase = getFarmRootMetadataBase();
|
|
9266
9490
|
return handleFarmDefaultMCPRequest(request, {
|
|
9267
9491
|
server: getFarmDefaultMCPServer(),
|
|
9268
9492
|
basePath: ${JSON.stringify(config.basePath)},
|
|
9269
9493
|
i18n: farmI18nConfig,
|
|
9494
|
+
metadataBase,
|
|
9270
9495
|
// Each page at the URL it answers at, as in development and as the sitemap lists it.
|
|
9271
9496
|
listPages: () =>
|
|
9272
9497
|
collectFarmDefaultMCPPages(
|
|
9273
9498
|
getFarmAgentListedPageRoutes().map((route) => ({ pattern: route.pattern, module: route.module })),
|
|
9274
9499
|
{
|
|
9275
9500
|
origin,
|
|
9501
|
+
metadataBase,
|
|
9276
9502
|
basePath: ${JSON.stringify(config.basePath)},
|
|
9277
9503
|
markdown: farmMarkdownConfig,${config.trailingSlash ? "\n trailingSlash: true," : ""}
|
|
9278
9504
|
i18n: farmI18nConfig,
|
|
@@ -9288,16 +9514,16 @@ async function handleFarmDefaultMCP(request) {
|
|
|
9288
9514
|
// gets its own request context, as for a direct request.
|
|
9289
9515
|
const farmDefaultMCPReadMarkdown = createFarmLlmsMarkdownReader((page) => fetch(page));
|
|
9290
9516
|
` : ""}
|
|
9291
|
-
// The origin llms.txt
|
|
9292
|
-
// request's origin, as for the sitemap and in development.
|
|
9517
|
+
// The origin llms.txt, llms-full.txt and list_pages link to: the root layout's metadataBase,
|
|
9518
|
+
// else the request's origin, as for the sitemap and in development.
|
|
9293
9519
|
function getFarmAgentOrigin(request) {
|
|
9520
|
+
return resolveFarmAgentOrigin(getFarmRootMetadataBase(), new URL(request.url).origin);
|
|
9521
|
+
}
|
|
9522
|
+
function getFarmRootMetadataBase() {
|
|
9294
9523
|
const rootLayout = layoutRoutes.find((layout) => layout.pattern === "/");
|
|
9295
|
-
return
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
: undefined,
|
|
9299
|
-
new URL(request.url).origin,
|
|
9300
|
-
);
|
|
9524
|
+
return rootLayout && rootLayout.module && rootLayout.module.metadata
|
|
9525
|
+
? rootLayout.module.metadata.metadataBase
|
|
9526
|
+
: undefined;
|
|
9301
9527
|
}
|
|
9302
9528
|
|
|
9303
9529
|
// Static pages and root metadata for llms.txt, built the same way as in development.
|
|
@@ -10682,6 +10908,12 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10682
10908
|
|
|
10683
10909
|
// Reads from here on belong to the page render, not to middleware.
|
|
10684
10910
|
const requestReadsBeforeRender = _getRequestReadCount();
|
|
10911
|
+
// A swr or cache route rule stores this page by URL for every visitor. Nitro hands Farm the
|
|
10912
|
+
// request without its cookies, Authorization, or any header the rule does not key on, so a
|
|
10913
|
+
// render that reads nothing of the request is that shared page, whatever its route config.
|
|
10914
|
+
const farmRouteRuleCached =
|
|
10915
|
+
Boolean(adapterContext?.routeRuleCache) &&
|
|
10916
|
+
(request.method === "GET" || request.method === "HEAD");
|
|
10685
10917
|
|
|
10686
10918
|
// Get the page component and metadata
|
|
10687
10919
|
let PageComponent = route.module.default;
|
|
@@ -10915,7 +11147,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10915
11147
|
${farmIslandsMode ? `// Islands mode: a route a shared cache may store (a PPR shell, a static page) renders
|
|
10916
11148
|
// whole for every request, so a cache hit stays a hit. Other routes leave out what the
|
|
10917
11149
|
// navigating browser keeps: the layouts it shows and the values it holds.
|
|
10918
|
-
const farmSharedCacheableRoute =
|
|
11150
|
+
const farmSharedCacheableRoute =
|
|
11151
|
+
farmRouteRuleCached || Boolean(getRouteSharedCacheControl(route, pprCanCache));
|
|
10919
11152
|
if (farmSharedCacheableRoute) ignoreFarmHeldValues();
|
|
10920
11153
|
const farmLayoutKeyOf = getFarmLayoutKey;
|
|
10921
11154
|
// A navigation the browser renders in its layout's React root rebuilds a server-tree page
|
|
@@ -11076,9 +11309,10 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11076
11309
|
wrappedElement = wrapWithFarmIntegrationProviders(wrappedElement);
|
|
11077
11310
|
return renderFarmElement(ReactDOMServer, wrappedElement, route.pattern, farmFlushToken);
|
|
11078
11311
|
};
|
|
11079
|
-
|
|
11312
|
+
// The head elements a component rendered go to the document's head (takeFarmRenderedHead).
|
|
11313
|
+
const renderedPage = takeFarmRenderedHead(${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
|
|
11080
11314
|
_runWithMiddlewareContext(middlewareContext, renderPageElement)
|
|
11081
|
-
)` : "await renderPageElement()"};
|
|
11315
|
+
)` : "await renderPageElement()"});
|
|
11082
11316
|
|
|
11083
11317
|
// A completed document is not a reusable PPR shell: it already contains
|
|
11084
11318
|
// the request's resolved Suspense content. Until the production runtime
|
|
@@ -11180,6 +11414,24 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11180
11414
|
middlewareData?.size ||
|
|
11181
11415
|
middlewareContext?.size
|
|
11182
11416
|
);
|
|
11417
|
+
if (farmRouteRuleCached && (renderedPage.stream || hasRequestScopedRender)) {
|
|
11418
|
+
// The route rule's cache refuses a private page: say why it renders on every request.
|
|
11419
|
+
emitFarmEvent({
|
|
11420
|
+
type: "cache.bypass",
|
|
11421
|
+
route: pathname,
|
|
11422
|
+
reason: pageStatus >= 400
|
|
11423
|
+
? "error-status"
|
|
11424
|
+
: renderReadRequest
|
|
11425
|
+
? "request-read"
|
|
11426
|
+
: middlewareData?.size || middlewareContext?.size
|
|
11427
|
+
? "middleware-data"
|
|
11428
|
+
: hasConfiguredRouteContext
|
|
11429
|
+
? "route-context"
|
|
11430
|
+
: renderedPage.stream
|
|
11431
|
+
? "suspense-stream"
|
|
11432
|
+
: "request-scoped",
|
|
11433
|
+
});
|
|
11434
|
+
}
|
|
11183
11435
|
const sharedCacheControl = getRouteSharedCacheControl(route, pprCanCache);
|
|
11184
11436
|
const responseHeaders = {
|
|
11185
11437
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -11189,8 +11441,16 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11189
11441
|
};
|
|
11190
11442
|
// An error status or a request-scoped render is never shareable, even when
|
|
11191
11443
|
// the PPR shell headers would otherwise grant a shared max-age.
|
|
11192
|
-
if (
|
|
11444
|
+
if (
|
|
11445
|
+
renderedPage.stream ||
|
|
11446
|
+
hasRequestScopedRender ||
|
|
11447
|
+
(!sharedCacheControl && !farmRouteRuleCached)
|
|
11448
|
+
) {
|
|
11193
11449
|
responseHeaders["Cache-Control"] = "private, no-store";
|
|
11450
|
+
} else if (responseHeaders["Cache-Control"] == null) {
|
|
11451
|
+
// A page with no policy of its own under a swr or cache route rule: the rule's cache
|
|
11452
|
+
// stores it and sends the rule's Cache-Control.
|
|
11453
|
+
delete responseHeaders["Cache-Control"];
|
|
11194
11454
|
}
|
|
11195
11455
|
const farmI18nSnapshot = getFarmI18nSnapshot();${farmIslandsMode ? `
|
|
11196
11456
|
// Islands mode: a navigation that names the values it holds, or the layouts it shows,
|
|
@@ -11292,7 +11552,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11292
11552
|
' <meta charset="utf-8">\\n' +
|
|
11293
11553
|
' ' + viewportTags + '\\n' +
|
|
11294
11554
|
(hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
|
|
11295
|
-
' <title>' + title + '</title>' + metaTags +
|
|
11555
|
+
(suppressDefaultTitle ? '' : ' <title>' + title + '</title>') + metaTags +
|
|
11556
|
+
(rendererHead ? '\\n ' + rendererHead : '') + '\\n' +
|
|
11296
11557
|
' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
|
|
11297
11558
|
' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule) + '\\n' +
|
|
11298
11559
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
@@ -11319,9 +11580,10 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11319
11580
|
}
|
|
11320
11581
|
try {
|
|
11321
11582
|
return createLateNotFoundRecovery(
|
|
11322
|
-
await
|
|
11583
|
+
await renderFarmCompleteDocument(
|
|
11584
|
+
ReactDOMServer,
|
|
11323
11585
|
wrapWithFarmIntegrationProviders(createFarmNotFoundElement(pathname)),
|
|
11324
|
-
|
|
11586
|
+
"not-found-recovery"
|
|
11325
11587
|
)
|
|
11326
11588
|
);
|
|
11327
11589
|
} catch (error) {
|
|
@@ -11479,7 +11741,9 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
11479
11741
|
pprCacheKey,
|
|
11480
11742
|
{ html: fullHtml },
|
|
11481
11743
|
{
|
|
11482
|
-
|
|
11744
|
+
// revalidatePath() takes the route path ("/pricing"), as the docs show, while the
|
|
11745
|
+
// shell answers the public one ("/console/fr/pricing"): either clears it.
|
|
11746
|
+
paths: [...new Set([pathname, getFarmRoutePathname(pathname)])],
|
|
11483
11747
|
tags: ["ppr"],
|
|
11484
11748
|
revalidate: pprConfig.revalidate ?? false,
|
|
11485
11749
|
}
|
|
@@ -11610,7 +11874,12 @@ ${servesDefaultMCP ? `
|
|
|
11610
11874
|
errorElement = wrapWithFarmIntegrationProviders(errorElement);
|
|
11611
11875
|
|
|
11612
11876
|
const renderErrorElement = () =>
|
|
11613
|
-
|
|
11877
|
+
renderFarmCompleteDocument(
|
|
11878
|
+
ReactDOMServer,
|
|
11879
|
+
// Islands mode: the error document writes its islands' values, as a page does.
|
|
11880
|
+
typeof farmIslandsRender === "function" ? farmIslandsRender(errorElement) : errorElement,
|
|
11881
|
+
"error:" + errorBoundaryMatch.route.pattern
|
|
11882
|
+
);
|
|
11614
11883
|
const errorHtml = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
|
|
11615
11884
|
_runWithMiddlewareContext(middlewareContext, renderErrorElement)
|
|
11616
11885
|
)` : "await renderErrorElement()"};
|
|
@@ -11751,7 +12020,7 @@ ${farmRendererDisabled ? `
|
|
|
11751
12020
|
}
|
|
11752
12021
|
notFoundElement = wrapWithFarmIntegrationProviders(notFoundElement);
|
|
11753
12022
|
|
|
11754
|
-
const html = await ReactDOMServer
|
|
12023
|
+
const html = await renderFarmCompleteDocument(ReactDOMServer, notFoundElement, "not-found");
|
|
11755
12024
|
// The layouts' and the not-found page's metadata, as the development renderer uses it.
|
|
11756
12025
|
const notFoundMetadata = renderMetadataHead(
|
|
11757
12026
|
await resolveFarmNotFoundMetadata(
|
|
@@ -12248,8 +12517,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12248
12517
|
const isVercel = preset === "vercel";
|
|
12249
12518
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
12250
12519
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
12251
|
-
const runtimeServerOutputDir = isVercel ?
|
|
12252
|
-
const ssrOutputDir =
|
|
12520
|
+
const runtimeServerOutputDir = isVercel ? path13.join(outputDir, "functions", "__nitro.func") : path13.join(outputDir, "server");
|
|
12521
|
+
const ssrOutputDir = path13.join(root, distDir, "ssr");
|
|
12253
12522
|
const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
|
|
12254
12523
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
12255
12524
|
(image) => image.sourceType === "module"
|
|
@@ -12371,15 +12640,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12371
12640
|
resolveHashedClientCssHref(clientOutputDir),
|
|
12372
12641
|
resolveHashedClientJsSrc(clientOutputDir),
|
|
12373
12642
|
resolveClientBootSrc(clientOutputDir),
|
|
12374
|
-
readFarmDocsModulePreloads(
|
|
12375
|
-
readFarmClientModulePreloads(
|
|
12643
|
+
readFarmDocsModulePreloads(path13.join(root, distDir)),
|
|
12644
|
+
readFarmClientModulePreloads(path13.join(root, distDir))
|
|
12376
12645
|
]);
|
|
12377
12646
|
let nativeStylesheets;
|
|
12378
12647
|
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
12379
12648
|
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
12380
12649
|
const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
|
|
12381
12650
|
await finalizeFarmMobileClient({
|
|
12382
|
-
buildDir:
|
|
12651
|
+
buildDir: path13.join(root, distDir),
|
|
12383
12652
|
clientOutputDir,
|
|
12384
12653
|
webEntry: clientJsSrc,
|
|
12385
12654
|
webBoot: clientBootSrc,
|
|
@@ -12418,12 +12687,12 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
12418
12687
|
await fs4.mkdir(ssrOutputDir, { recursive: true });
|
|
12419
12688
|
await Promise.all(
|
|
12420
12689
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
12421
|
-
const filePath =
|
|
12422
|
-
await fs4.mkdir(
|
|
12690
|
+
const filePath = path13.join(ssrOutputDir, fileName);
|
|
12691
|
+
await fs4.mkdir(path13.dirname(filePath), { recursive: true });
|
|
12423
12692
|
await fs4.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
12424
12693
|
})
|
|
12425
12694
|
);
|
|
12426
|
-
const nitroEntryPath =
|
|
12695
|
+
const nitroEntryPath = path13.join(ssrOutputDir, "nitro-entry.mjs");
|
|
12427
12696
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
12428
12697
|
const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
|
|
12429
12698
|
const nitroEntryCode = `
|
|
@@ -12601,7 +12870,9 @@ ${hasNitroCacheRouteRules ? " let farmGuardedResponse = false\n" : ""} const r
|
|
|
12601
12870
|
}${hasNitroCacheRouteRules ? `
|
|
12602
12871
|
const farmCacheControl = response.headers.get('cache-control')
|
|
12603
12872
|
if (
|
|
12604
|
-
|
|
12873
|
+
// A guarded response, or any response Farm kept private under a swr or cache rule: the
|
|
12874
|
+
// rule's cache does not store it, and the rule's public Cache-Control must not reach a CDN.
|
|
12875
|
+
(farmGuardedResponse || event.context?.routeRules?.cache) &&
|
|
12605
12876
|
farmCacheControl &&
|
|
12606
12877
|
FARM_PRIVATE_CACHE_DIRECTIVE.test(farmCacheControl)
|
|
12607
12878
|
) {
|
|
@@ -12639,20 +12910,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
12639
12910
|
);
|
|
12640
12911
|
}
|
|
12641
12912
|
await fs4.writeFile(
|
|
12642
|
-
|
|
12913
|
+
path13.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
|
|
12643
12914
|
FARM_DESKTOP_ENV_MODULE_SOURCE
|
|
12644
12915
|
);
|
|
12645
12916
|
}
|
|
12646
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
12917
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path13.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
12647
12918
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
12648
12919
|
await fs4.writeFile(
|
|
12649
|
-
|
|
12920
|
+
path13.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
12650
12921
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
12651
12922
|
);
|
|
12652
12923
|
await fs4.writeFile(
|
|
12653
12924
|
farmNodeServerEntryPath,
|
|
12654
12925
|
createFarmNodeServerEntry({
|
|
12655
|
-
nitroEntryFile:
|
|
12926
|
+
nitroEntryFile: path13.basename(nitroEntryPath),
|
|
12656
12927
|
nodeAdapterModule,
|
|
12657
12928
|
server: config.server,
|
|
12658
12929
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
|
|
@@ -12660,12 +12931,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
12660
12931
|
})
|
|
12661
12932
|
);
|
|
12662
12933
|
}
|
|
12663
|
-
const farmBunServerEntryPath = preset === "bun" ?
|
|
12934
|
+
const farmBunServerEntryPath = preset === "bun" ? path13.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
|
|
12664
12935
|
if (farmBunServerEntryPath) {
|
|
12665
12936
|
await fs4.writeFile(
|
|
12666
12937
|
farmBunServerEntryPath,
|
|
12667
12938
|
createFarmBunServerEntry({
|
|
12668
|
-
nitroEntryFile:
|
|
12939
|
+
nitroEntryFile: path13.basename(nitroEntryPath),
|
|
12669
12940
|
bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
|
|
12670
12941
|
server: config.server,
|
|
12671
12942
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
|
|
@@ -12673,7 +12944,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12673
12944
|
})
|
|
12674
12945
|
);
|
|
12675
12946
|
}
|
|
12676
|
-
const farmNetlifyEntryPath = preset === "netlify" ?
|
|
12947
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path13.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
12677
12948
|
if (farmNetlifyEntryPath) {
|
|
12678
12949
|
await fs4.writeFile(
|
|
12679
12950
|
farmNetlifyEntryPath,
|
|
@@ -12682,7 +12953,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12682
12953
|
})
|
|
12683
12954
|
);
|
|
12684
12955
|
}
|
|
12685
|
-
const farmCloudflareEnvPath = preset === "cloudflare-pages" ?
|
|
12956
|
+
const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path13.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
|
|
12686
12957
|
if (farmCloudflareEnvPath) {
|
|
12687
12958
|
await fs4.writeFile(
|
|
12688
12959
|
farmCloudflareEnvPath,
|
|
@@ -12701,7 +12972,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
12701
12972
|
const configuredNitroRouteRules = nitroRouteRulesBelowBasePath(
|
|
12702
12973
|
varyFarmNitroCacheRules(routeRulesToNitroRouteRules(config.routeRules), [
|
|
12703
12974
|
...config.md.enabled ? ["accept"] : [],
|
|
12704
|
-
...shouldBuildFarmMobileClient(config) ? ["x-farm-shell"] : []
|
|
12975
|
+
...shouldBuildFarmMobileClient(config) ? ["x-farm-shell"] : [],
|
|
12976
|
+
...resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands" ? ["f-layouts"] : []
|
|
12705
12977
|
]),
|
|
12706
12978
|
config.basePath,
|
|
12707
12979
|
resolveFarmAPIServerBasePath(config.api)
|
|
@@ -12729,6 +13001,18 @@ function toFarmNodeResponse(request, response) {
|
|
|
12729
13001
|
];
|
|
12730
13002
|
})
|
|
12731
13003
|
);
|
|
13004
|
+
const immutableAssets = isVercel ? { publicAssets: [], routeRules: {} } : planFarmImmutableAssets({
|
|
13005
|
+
clientOutputDir,
|
|
13006
|
+
files: await listFarmClientOutputFiles(clientOutputDir),
|
|
13007
|
+
routeRules: configuredNitroRouteRules,
|
|
13008
|
+
routePaths: [
|
|
13009
|
+
...[...routeManager.getRoutes().keys()].map(
|
|
13010
|
+
(pattern) => applyFarmBasePath(pattern, config.basePath)
|
|
13011
|
+
),
|
|
13012
|
+
...apiRouteManager.getRoutes().keys(),
|
|
13013
|
+
resolveFarmAPIServerBasePath(config.api)
|
|
13014
|
+
]
|
|
13015
|
+
});
|
|
12732
13016
|
let nitroConfig = {
|
|
12733
13017
|
preset,
|
|
12734
13018
|
...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
|
|
@@ -12743,17 +13027,13 @@ function toFarmNodeResponse(request, response) {
|
|
|
12743
13027
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
12744
13028
|
serverDir: false,
|
|
12745
13029
|
serverEntry: false,
|
|
12746
|
-
buildDir:
|
|
13030
|
+
buildDir: path13.join(root, distDir, ".nitro"),
|
|
12747
13031
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
12748
13032
|
compatibilityDate: "2024-12-01",
|
|
12749
13033
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
maxAge: 31536e3,
|
|
12754
|
-
baseURL: "/"
|
|
12755
|
-
}
|
|
12756
|
-
],
|
|
13034
|
+
// Nitro gives the root directory no Cache-Control on any preset (it falls through to the
|
|
13035
|
+
// app), so public files keep revalidating; the hashed directories carry their own maxAge.
|
|
13036
|
+
publicAssets: [{ dir: clientOutputDir, baseURL: "/" }, ...immutableAssets.publicAssets],
|
|
12757
13037
|
// A self-hosted Node server sends static files itself, so precompress them
|
|
12758
13038
|
// with gzip and let Nitro serve that by Accept-Encoding. Brotli at Nitro's
|
|
12759
13039
|
// fixed top quality cost a docs app ~20 s of build CPU for a small further
|
|
@@ -12807,6 +13087,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12807
13087
|
"/**": {
|
|
12808
13088
|
prerender: false
|
|
12809
13089
|
},
|
|
13090
|
+
...immutableAssets.routeRules,
|
|
12810
13091
|
...configuredNitroRouteRules,
|
|
12811
13092
|
// Exact user rules must retain their runtime settings without replacing
|
|
12812
13093
|
// the headers and prerender marker generated for a safe physical page.
|
|
@@ -12835,7 +13116,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12835
13116
|
if (pluginManager) {
|
|
12836
13117
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
12837
13118
|
}
|
|
12838
|
-
const expectedServerDir =
|
|
13119
|
+
const expectedServerDir = path13.join(outputDir, "server");
|
|
12839
13120
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
12840
13121
|
(key) => key !== "external" && key !== "plugins"
|
|
12841
13122
|
);
|
|
@@ -12850,10 +13131,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
12850
13131
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
12851
13132
|
const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && Boolean(
|
|
12852
13133
|
nitroConfig.handlers?.some(
|
|
12853
|
-
(handler) =>
|
|
13134
|
+
(handler) => path13.resolve(handler?.handler || "") === nitroEntryPath
|
|
12854
13135
|
)
|
|
12855
13136
|
);
|
|
12856
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms &&
|
|
13137
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path13.resolve(nitroConfig.output?.serverDir || "") === path13.resolve(expectedServerDir);
|
|
12857
13138
|
const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
|
|
12858
13139
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
12859
13140
|
if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
|
|
@@ -12959,8 +13240,8 @@ function toFarmNodeResponse(request, response) {
|
|
|
12959
13240
|
};
|
|
12960
13241
|
prerendererConfig.output = {
|
|
12961
13242
|
...prerendererConfig.output,
|
|
12962
|
-
serverDir:
|
|
12963
|
-
prerendererConfig.buildDir ??
|
|
13243
|
+
serverDir: path13.join(
|
|
13244
|
+
prerendererConfig.buildDir ?? path13.join(root, distDir, ".nitro"),
|
|
12964
13245
|
"prerender"
|
|
12965
13246
|
)
|
|
12966
13247
|
};
|
|
@@ -12979,7 +13260,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
12979
13260
|
const prerenderServerDir = prerenderer.options.output.serverDir;
|
|
12980
13261
|
await copyPrebuiltSSRBundle(
|
|
12981
13262
|
ssrBundle,
|
|
12982
|
-
|
|
13263
|
+
path13.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
12983
13264
|
null,
|
|
12984
13265
|
fs4
|
|
12985
13266
|
);
|
|
@@ -13055,7 +13336,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13055
13336
|
const copyResults = await Promise.allSettled([
|
|
13056
13337
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
13057
13338
|
prebuiltSSRFilesResult.value,
|
|
13058
|
-
|
|
13339
|
+
path13.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
13059
13340
|
fs4
|
|
13060
13341
|
) : Promise.resolve(),
|
|
13061
13342
|
runtimeCopyPromise
|
|
@@ -13065,14 +13346,14 @@ function toFarmNodeResponse(request, response) {
|
|
|
13065
13346
|
);
|
|
13066
13347
|
if (failedCopy) throw failedCopy.reason;
|
|
13067
13348
|
if (canReusePrebuiltSSR) {
|
|
13068
|
-
await registerPrebuiltSSRPackageImport(
|
|
13349
|
+
await registerPrebuiltSSRPackageImport(path13.join(outputDir, "server"), ssrEntryFile, fs4);
|
|
13069
13350
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
13070
13351
|
}
|
|
13071
13352
|
if (useRolldownBuilder) {
|
|
13072
13353
|
logger.info("\u26A1 Built the Node adapter with Rolldown");
|
|
13073
13354
|
}
|
|
13074
13355
|
if (preset === "node-server" && !desktopServerEntry) {
|
|
13075
|
-
await installFarmCompileCacheLauncher(
|
|
13356
|
+
await installFarmCompileCacheLauncher(path13.join(outputDir, "server"), fs4);
|
|
13076
13357
|
}
|
|
13077
13358
|
if (preset.startsWith("cloudflare")) {
|
|
13078
13359
|
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs4);
|
|
@@ -13095,7 +13376,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
13095
13376
|
routeRuntimeManifest,
|
|
13096
13377
|
farmCron.provider === "host" ? farmCron.jobs : [],
|
|
13097
13378
|
{
|
|
13098
|
-
buildDir:
|
|
13379
|
+
buildDir: path13.join(root, distDir),
|
|
13099
13380
|
middlewareRoutes: edgeMiddlewareRoutes,
|
|
13100
13381
|
guardedPages: edgeGuardedPrerenderRoutes
|
|
13101
13382
|
},
|
|
@@ -13109,16 +13390,16 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
13109
13390
|
return {
|
|
13110
13391
|
dir: outputDir,
|
|
13111
13392
|
...preset === "node-server" ? {
|
|
13112
|
-
serverDir:
|
|
13113
|
-
publicDir:
|
|
13393
|
+
serverDir: path13.join(outputDir, "server"),
|
|
13394
|
+
publicDir: path13.join(outputDir, "public")
|
|
13114
13395
|
} : isVercel ? {
|
|
13115
|
-
serverDir:
|
|
13116
|
-
publicDir:
|
|
13396
|
+
serverDir: path13.join(outputDir, "functions", "__nitro.func"),
|
|
13397
|
+
publicDir: path13.join(outputDir, "static")
|
|
13117
13398
|
} : {}
|
|
13118
13399
|
};
|
|
13119
13400
|
}
|
|
13120
13401
|
async function populateCloudflareProcessEnv(serverDir, fs4) {
|
|
13121
|
-
const wranglerPath =
|
|
13402
|
+
const wranglerPath = path13.join(serverDir, "wrangler.json");
|
|
13122
13403
|
let source;
|
|
13123
13404
|
try {
|
|
13124
13405
|
source = await fs4.readFile(wranglerPath, "utf8");
|
|
@@ -13146,8 +13427,8 @@ async function writeSSRBundleFiles(files, targetDir, fs4) {
|
|
|
13146
13427
|
await fs4.rm(targetDir, { recursive: true, force: true });
|
|
13147
13428
|
await Promise.all(
|
|
13148
13429
|
files.map(async ({ fileName, contents }) => {
|
|
13149
|
-
const targetPath =
|
|
13150
|
-
await fs4.mkdir(
|
|
13430
|
+
const targetPath = path13.join(targetDir, fileName);
|
|
13431
|
+
await fs4.mkdir(path13.dirname(targetPath), { recursive: true });
|
|
13151
13432
|
await fs4.writeFile(targetPath, contents);
|
|
13152
13433
|
})
|
|
13153
13434
|
);
|
|
@@ -13156,8 +13437,8 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs4) {
|
|
|
13156
13437
|
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs4);
|
|
13157
13438
|
}
|
|
13158
13439
|
async function installFarmCompileCacheLauncher(serverDir, fs4) {
|
|
13159
|
-
const entryPath =
|
|
13160
|
-
const serverPath =
|
|
13440
|
+
const entryPath = path13.join(serverDir, "index.mjs");
|
|
13441
|
+
const serverPath = path13.join(serverDir, FARM_SERVER_MODULE_FILE);
|
|
13161
13442
|
const entry = await fs4.readFile(entryPath, "utf8").catch((error) => {
|
|
13162
13443
|
if (error.code === "ENOENT") return null;
|
|
13163
13444
|
throw error;
|
|
@@ -13166,11 +13447,11 @@ async function installFarmCompileCacheLauncher(serverDir, fs4) {
|
|
|
13166
13447
|
if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
|
|
13167
13448
|
await fs4.rename(entryPath, serverPath);
|
|
13168
13449
|
await fs4.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
|
|
13169
|
-
await fs4.rm(
|
|
13450
|
+
await fs4.rm(path13.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
|
|
13170
13451
|
return true;
|
|
13171
13452
|
}
|
|
13172
13453
|
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
|
|
13173
|
-
const packagePath =
|
|
13454
|
+
const packagePath = path13.join(serverDir, "package.json");
|
|
13174
13455
|
const packageJSON = await fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13175
13456
|
if (error.code === "ENOENT") return { type: "module" };
|
|
13176
13457
|
throw error;
|
|
@@ -13199,18 +13480,18 @@ async function moveVercelOutputPath(src, dest, fs4) {
|
|
|
13199
13480
|
await fs4.rm(src, { recursive: true, force: true });
|
|
13200
13481
|
}
|
|
13201
13482
|
async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
|
|
13202
|
-
const serverDir =
|
|
13203
|
-
const functionsDir =
|
|
13204
|
-
const nitroFuncDir =
|
|
13205
|
-
const staticDir =
|
|
13206
|
-
const publicDir =
|
|
13483
|
+
const serverDir = path13.join(outputDir, "server");
|
|
13484
|
+
const functionsDir = path13.join(outputDir, "functions");
|
|
13485
|
+
const nitroFuncDir = path13.join(functionsDir, "__nitro.func");
|
|
13486
|
+
const staticDir = path13.join(outputDir, "static");
|
|
13487
|
+
const publicDir = path13.join(outputDir, "public");
|
|
13207
13488
|
await fs4.mkdir(nitroFuncDir, { recursive: true });
|
|
13208
13489
|
const serverContents = await fs4.readdir(serverDir).catch((error) => {
|
|
13209
13490
|
if (error.code === "ENOENT") return [];
|
|
13210
13491
|
throw error;
|
|
13211
13492
|
});
|
|
13212
13493
|
for (const file of serverContents) {
|
|
13213
|
-
await moveVercelOutputPath(
|
|
13494
|
+
await moveVercelOutputPath(path13.join(serverDir, file), path13.join(nitroFuncDir, file), fs4);
|
|
13214
13495
|
}
|
|
13215
13496
|
if (serverContents.length > 0) await fs4.rm(serverDir, { recursive: true, force: true });
|
|
13216
13497
|
try {
|
|
@@ -13220,7 +13501,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13220
13501
|
}
|
|
13221
13502
|
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4);
|
|
13222
13503
|
await copyPrismaClientForVercel(root, nitroFuncDir, fs4);
|
|
13223
|
-
const configPath =
|
|
13504
|
+
const configPath = path13.join(outputDir, "config.json");
|
|
13224
13505
|
const configContent = await fs4.readFile(configPath, "utf-8");
|
|
13225
13506
|
const vercelConfig = JSON.parse(configContent);
|
|
13226
13507
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
@@ -13246,7 +13527,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
13246
13527
|
vercelConfig.routes = buildFarmVercelRoutes({
|
|
13247
13528
|
presetRoutes: Array.isArray(vercelConfig.routes) ? vercelConfig.routes : [],
|
|
13248
13529
|
runtimeRoutes,
|
|
13249
|
-
middlewareRoutes: edgeMiddlewareRoutes.length > 0 ?
|
|
13530
|
+
middlewareRoutes: edgeMiddlewareRoutes.length > 0 ? createFarmVercelEdgeMiddlewareRoutes(edgeMiddleware.guardedPages, config.basePath) : [],
|
|
13250
13531
|
canonicalSlashRoutes: createFarmVercelCanonicalSlashRoutes(prerenderedPages)
|
|
13251
13532
|
});
|
|
13252
13533
|
const vercelConfigWithWorkflowCrons = applyFarmWorkflowVercelCrons(
|
|
@@ -13264,7 +13545,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
|
|
|
13264
13545
|
mainRoot,
|
|
13265
13546
|
root,
|
|
13266
13547
|
config.srcDir,
|
|
13267
|
-
|
|
13548
|
+
path13.join(nitroFuncDir, "farm-docs-content"),
|
|
13268
13549
|
fs4
|
|
13269
13550
|
);
|
|
13270
13551
|
for (const [index, docsRoot] of extraRoots.entries()) {
|
|
@@ -13272,7 +13553,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
|
|
|
13272
13553
|
docsRoot,
|
|
13273
13554
|
root,
|
|
13274
13555
|
config.srcDir,
|
|
13275
|
-
|
|
13556
|
+
path13.join(nitroFuncDir, "farm-docs-roots", String(index)),
|
|
13276
13557
|
fs4
|
|
13277
13558
|
);
|
|
13278
13559
|
}
|
|
@@ -13290,18 +13571,18 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
|
|
|
13290
13571
|
);
|
|
13291
13572
|
}
|
|
13292
13573
|
await fs4.rm(bundledContentDir, { recursive: true, force: true });
|
|
13293
|
-
await fs4.mkdir(
|
|
13574
|
+
await fs4.mkdir(path13.dirname(bundledContentDir), { recursive: true });
|
|
13294
13575
|
await fs4.cp(docsContentDir, bundledContentDir, {
|
|
13295
13576
|
recursive: true,
|
|
13296
13577
|
force: true,
|
|
13297
13578
|
dereference: true
|
|
13298
13579
|
});
|
|
13299
13580
|
await fs4.writeFile(
|
|
13300
|
-
|
|
13581
|
+
path13.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
13301
13582
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
13302
13583
|
`
|
|
13303
13584
|
);
|
|
13304
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
13585
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path13.relative(root, docsContentDir)}`);
|
|
13305
13586
|
}
|
|
13306
13587
|
function resolveServerFunctionPlatform(preset) {
|
|
13307
13588
|
return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
|
|
@@ -13318,7 +13599,7 @@ function platformFieldAllows(field, value) {
|
|
|
13318
13599
|
}
|
|
13319
13600
|
async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
13320
13601
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
13321
|
-
const projectRequire = createRequire2(
|
|
13602
|
+
const projectRequire = createRequire2(path13.join(root, "package.json"));
|
|
13322
13603
|
let sharpRequire = projectRequire;
|
|
13323
13604
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
13324
13605
|
try {
|
|
@@ -13328,10 +13609,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13328
13609
|
}
|
|
13329
13610
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
13330
13611
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
13331
|
-
const stageRoot =
|
|
13612
|
+
const stageRoot = path13.join(root, distDir, "tmp");
|
|
13332
13613
|
await fs4.mkdir(stageRoot, { recursive: true });
|
|
13333
|
-
const stageDir = await fs4.mkdtemp(
|
|
13334
|
-
const targetNodeModules =
|
|
13614
|
+
const stageDir = await fs4.mkdtemp(path13.join(stageRoot, "sharp-runtime-"));
|
|
13615
|
+
const targetNodeModules = path13.join(stageDir, "node_modules");
|
|
13335
13616
|
function copyPackage(packageName, parentRequire) {
|
|
13336
13617
|
const activeCopy = packageCopies.get(packageName);
|
|
13337
13618
|
if (activeCopy) return activeCopy;
|
|
@@ -13344,10 +13625,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13344
13625
|
if (!packageJsonPath) return;
|
|
13345
13626
|
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
|
|
13346
13627
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
13347
|
-
const packageDir =
|
|
13348
|
-
const targetDir =
|
|
13628
|
+
const packageDir = path13.dirname(packageJsonPath);
|
|
13629
|
+
const targetDir = path13.join(targetNodeModules, ...packageName.split("/"));
|
|
13349
13630
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
13350
|
-
await fs4.mkdir(
|
|
13631
|
+
await fs4.mkdir(path13.dirname(targetDir), { recursive: true });
|
|
13351
13632
|
const packageRequire = createRequire2(packageJsonPath);
|
|
13352
13633
|
const dependencies = {
|
|
13353
13634
|
...packageJson.dependencies,
|
|
@@ -13382,8 +13663,8 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
13382
13663
|
};
|
|
13383
13664
|
}
|
|
13384
13665
|
async function installStagedSharpRuntime(staged, nitroFuncDir, fs4) {
|
|
13385
|
-
const stagedNodeModules =
|
|
13386
|
-
const targetNodeModules =
|
|
13666
|
+
const stagedNodeModules = path13.join(staged.stageDir, "node_modules");
|
|
13667
|
+
const targetNodeModules = path13.join(nitroFuncDir, "node_modules");
|
|
13387
13668
|
try {
|
|
13388
13669
|
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs4);
|
|
13389
13670
|
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
|
|
@@ -13411,8 +13692,8 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
|
13411
13692
|
const entries = await fs4.readdir(sourceDir, { withFileTypes: true });
|
|
13412
13693
|
await settleAllOrThrow(
|
|
13413
13694
|
entries.map(async (entry) => {
|
|
13414
|
-
const sourcePath =
|
|
13415
|
-
const targetPath =
|
|
13695
|
+
const sourcePath = path13.join(sourceDir, entry.name);
|
|
13696
|
+
const targetPath = path13.join(targetDir, entry.name);
|
|
13416
13697
|
try {
|
|
13417
13698
|
await fs4.rename(sourcePath, targetPath);
|
|
13418
13699
|
return;
|
|
@@ -13439,13 +13720,13 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
|
13439
13720
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
13440
13721
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
13441
13722
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
13442
|
-
const file = generated.modulePath ? toPosixPath(
|
|
13723
|
+
const file = generated.modulePath ? toPosixPath(path13.relative(root, generated.modulePath)) : "";
|
|
13443
13724
|
throw new Error(
|
|
13444
13725
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
13445
13726
|
);
|
|
13446
13727
|
}
|
|
13447
13728
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
13448
|
-
const projectRequire = createRequire2(
|
|
13729
|
+
const projectRequire = createRequire2(path13.join(root, "package.json"));
|
|
13449
13730
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
13450
13731
|
if (packageJsonPath) return packageJsonPath;
|
|
13451
13732
|
try {
|
|
@@ -13458,9 +13739,9 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
|
|
|
13458
13739
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
13459
13740
|
if (!packageJsonPath) return;
|
|
13460
13741
|
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
|
|
13461
|
-
const packageDir =
|
|
13462
|
-
const targetDir =
|
|
13463
|
-
await fs4.mkdir(
|
|
13742
|
+
const packageDir = path13.dirname(packageJsonPath);
|
|
13743
|
+
const targetDir = path13.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
13744
|
+
await fs4.mkdir(path13.dirname(targetDir), { recursive: true });
|
|
13464
13745
|
await fs4.cp(packageDir, targetDir, {
|
|
13465
13746
|
recursive: true,
|
|
13466
13747
|
force: true,
|
|
@@ -13476,7 +13757,7 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
|
|
|
13476
13757
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
13477
13758
|
}
|
|
13478
13759
|
async function readNitroOutputPackage(outputDir, fs4) {
|
|
13479
|
-
const packagePath =
|
|
13760
|
+
const packagePath = path13.join(outputDir, "package.json");
|
|
13480
13761
|
return fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
13481
13762
|
if (error.code === "ENOENT") return {};
|
|
13482
13763
|
throw error;
|
|
@@ -13485,7 +13766,7 @@ async function readNitroOutputPackage(outputDir, fs4) {
|
|
|
13485
13766
|
async function writeNitroOutputPackage(outputDir, packageJson, fs4) {
|
|
13486
13767
|
await fs4.mkdir(outputDir, { recursive: true });
|
|
13487
13768
|
await fs4.writeFile(
|
|
13488
|
-
|
|
13769
|
+
path13.join(outputDir, "package.json"),
|
|
13489
13770
|
`${JSON.stringify(packageJson, null, 2)}
|
|
13490
13771
|
`
|
|
13491
13772
|
);
|
|
@@ -13501,9 +13782,9 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
13501
13782
|
}
|
|
13502
13783
|
}
|
|
13503
13784
|
try {
|
|
13504
|
-
let directory =
|
|
13505
|
-
while (directory !==
|
|
13506
|
-
const candidate =
|
|
13785
|
+
let directory = path13.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
13786
|
+
while (directory !== path13.dirname(directory)) {
|
|
13787
|
+
const candidate = path13.join(directory, "package.json");
|
|
13507
13788
|
if (existsSync2(candidate)) {
|
|
13508
13789
|
try {
|
|
13509
13790
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
@@ -13511,23 +13792,23 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
13511
13792
|
} catch {
|
|
13512
13793
|
}
|
|
13513
13794
|
}
|
|
13514
|
-
if (
|
|
13515
|
-
directory =
|
|
13795
|
+
if (path13.basename(directory) === "node_modules") break;
|
|
13796
|
+
directory = path13.dirname(directory);
|
|
13516
13797
|
}
|
|
13517
13798
|
} catch {
|
|
13518
13799
|
}
|
|
13519
13800
|
return null;
|
|
13520
13801
|
}
|
|
13521
13802
|
async function resolveProjectInstalledPackageDir(root, packageName, fs4) {
|
|
13522
|
-
let directory =
|
|
13803
|
+
let directory = path13.resolve(root);
|
|
13523
13804
|
while (true) {
|
|
13524
|
-
const candidate =
|
|
13805
|
+
const candidate = path13.join(directory, "node_modules", ...packageName.split("/"));
|
|
13525
13806
|
try {
|
|
13526
13807
|
const packageDir = await fs4.realpath(candidate);
|
|
13527
|
-
if ((await fs4.stat(
|
|
13808
|
+
if ((await fs4.stat(path13.join(packageDir, "package.json"))).isFile()) return packageDir;
|
|
13528
13809
|
} catch {
|
|
13529
13810
|
}
|
|
13530
|
-
const parent =
|
|
13811
|
+
const parent = path13.dirname(directory);
|
|
13531
13812
|
if (parent === directory) return null;
|
|
13532
13813
|
directory = parent;
|
|
13533
13814
|
}
|
|
@@ -13535,16 +13816,16 @@ async function resolveProjectInstalledPackageDir(root, packageName, fs4) {
|
|
|
13535
13816
|
async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
|
|
13536
13817
|
const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs4);
|
|
13537
13818
|
if (!prismaClientDir) return;
|
|
13538
|
-
const generatedClientDir =
|
|
13819
|
+
const generatedClientDir = path13.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
13539
13820
|
try {
|
|
13540
13821
|
await fs4.access(generatedClientDir);
|
|
13541
13822
|
} catch {
|
|
13542
13823
|
return;
|
|
13543
13824
|
}
|
|
13544
|
-
const targetNodeModules =
|
|
13545
|
-
const targetPrismaScopeDir =
|
|
13546
|
-
const targetGeneratedDir =
|
|
13547
|
-
const targetClientDir =
|
|
13825
|
+
const targetNodeModules = path13.join(nitroFuncDir, "node_modules");
|
|
13826
|
+
const targetPrismaScopeDir = path13.join(targetNodeModules, "@prisma");
|
|
13827
|
+
const targetGeneratedDir = path13.join(targetNodeModules, ".prisma", "client");
|
|
13828
|
+
const targetClientDir = path13.join(targetPrismaScopeDir, "client");
|
|
13548
13829
|
await fs4.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
13549
13830
|
await fs4.cp(prismaClientDir, targetClientDir, {
|
|
13550
13831
|
recursive: true,
|
|
@@ -13554,7 +13835,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
|
|
|
13554
13835
|
recursive: true,
|
|
13555
13836
|
force: true
|
|
13556
13837
|
});
|
|
13557
|
-
const clientPackagePath =
|
|
13838
|
+
const clientPackagePath = path13.join(prismaClientDir, "package.json");
|
|
13558
13839
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
13559
13840
|
readNitroOutputPackage(nitroFuncDir, fs4),
|
|
13560
13841
|
fs4.readFile(clientPackagePath, "utf-8")
|
|
@@ -13740,9 +14021,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
13740
14021
|
} else {
|
|
13741
14022
|
const { build: legacyViteBuild } = await import("vite");
|
|
13742
14023
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
13743
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
14024
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path14.join(root, distDir, "client"));
|
|
13744
14025
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
13745
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
14026
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path14.join(root, distDir, "server"));
|
|
13746
14027
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
13747
14028
|
await buildNitro(
|
|
13748
14029
|
config,
|
|
@@ -13844,8 +14125,8 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
13844
14125
|
root,
|
|
13845
14126
|
// Vite keys its pre-bundled dependencies on the config, mode included, so this server and
|
|
13846
14127
|
// `farm dev` sharing one cache would each rebuild it after the other ran.
|
|
13847
|
-
cacheDir:
|
|
13848
|
-
|
|
14128
|
+
cacheDir: path14.join(
|
|
14129
|
+
path14.resolve(root, viteConfig.cacheDir ?? path14.join("node_modules", ".vite")),
|
|
13849
14130
|
"farm-build"
|
|
13850
14131
|
),
|
|
13851
14132
|
configFile: false,
|
|
@@ -13879,7 +14160,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
13879
14160
|
}
|
|
13880
14161
|
async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
13881
14162
|
const { farmI18nClientBridgePlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
13882
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
14163
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
13883
14164
|
const pluginManager = new PluginManager2({
|
|
13884
14165
|
config,
|
|
13885
14166
|
isDev: false,
|
|
@@ -13906,7 +14187,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
13906
14187
|
}
|
|
13907
14188
|
async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
13908
14189
|
const { farmI18nClientBridgePlugin, farmPlugin } = await import("./vite.mjs");
|
|
13909
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
14190
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
|
|
13910
14191
|
const pluginManager = new PluginManager2({
|
|
13911
14192
|
config,
|
|
13912
14193
|
isDev: false,
|
|
@@ -13938,16 +14219,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
13938
14219
|
});
|
|
13939
14220
|
}
|
|
13940
14221
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
13941
|
-
const appDir =
|
|
14222
|
+
const appDir = path14.join(root, srcDir, "app");
|
|
13942
14223
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
13943
|
-
const candidate =
|
|
14224
|
+
const candidate = path14.join(appDir, `page${extension}`);
|
|
13944
14225
|
if (existsSync3(candidate)) return candidate;
|
|
13945
14226
|
}
|
|
13946
|
-
return
|
|
14227
|
+
return path14.join(appDir, "page.tsx");
|
|
13947
14228
|
}
|
|
13948
14229
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
13949
14230
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
13950
|
-
import("./nitro-
|
|
14231
|
+
import("./nitro-72TFIGGO.mjs"),
|
|
13951
14232
|
import("nitro/builder")
|
|
13952
14233
|
]);
|
|
13953
14234
|
let nitroConfig = await createNitroConfig(
|
|
@@ -13961,18 +14242,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
13961
14242
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
13962
14243
|
}
|
|
13963
14244
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
13964
|
-
const serverOutputDir =
|
|
13965
|
-
const publicOutputDir =
|
|
14245
|
+
const serverOutputDir = path14.join(outputDir, "server");
|
|
14246
|
+
const publicOutputDir = path14.join(outputDir, "public");
|
|
13966
14247
|
const { mkdir, cp } = await import("fs/promises");
|
|
13967
14248
|
await mkdir(serverOutputDir, { recursive: true });
|
|
13968
14249
|
await mkdir(publicOutputDir, { recursive: true });
|
|
13969
|
-
const clientDir =
|
|
14250
|
+
const clientDir = path14.join(root, distDir, "client");
|
|
13970
14251
|
try {
|
|
13971
14252
|
await mkdir(publicOutputDir, { recursive: true });
|
|
13972
14253
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
13973
14254
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
13974
|
-
const manifestPath =
|
|
13975
|
-
const assetsDir =
|
|
14255
|
+
const manifestPath = path14.join(publicOutputDir, "farm-client-manifest.json");
|
|
14256
|
+
const assetsDir = path14.join(publicOutputDir, "assets");
|
|
13976
14257
|
const manifestExists = await import("fs/promises").then(
|
|
13977
14258
|
(fs4) => fs4.access(manifestPath).then(() => true).catch(() => false)
|
|
13978
14259
|
);
|
|
@@ -13988,8 +14269,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
13988
14269
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
13989
14270
|
throw error;
|
|
13990
14271
|
}
|
|
13991
|
-
const serverDir =
|
|
13992
|
-
const nitroServerDir =
|
|
14272
|
+
const serverDir = path14.join(root, distDir, "server");
|
|
14273
|
+
const nitroServerDir = path14.join(root, distDir, ".nitro", "server", "farm");
|
|
13993
14274
|
try {
|
|
13994
14275
|
await mkdir(nitroServerDir, { recursive: true });
|
|
13995
14276
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -13998,7 +14279,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
13998
14279
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
13999
14280
|
}
|
|
14000
14281
|
const nitro = await createNitro(nitroConfig);
|
|
14001
|
-
const registryPath =
|
|
14282
|
+
const registryPath = path14.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
14002
14283
|
try {
|
|
14003
14284
|
const { farmRegistry } = await import(
|
|
14004
14285
|
/* @vite-ignore */
|
|
@@ -14015,7 +14296,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
14015
14296
|
}
|
|
14016
14297
|
farmRegistry.routePaths = routePaths;
|
|
14017
14298
|
try {
|
|
14018
|
-
const clientManifestPath =
|
|
14299
|
+
const clientManifestPath = path14.join(root, distDir, "client", "farm-client-manifest.json");
|
|
14019
14300
|
const { readFile } = await import("fs/promises");
|
|
14020
14301
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
14021
14302
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|