@farm.js/plugin 0.1.18 → 0.1.20
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/api/index.d.ts.map +1 -1
- package/dist/api/index.js +6 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +4 -18
- package/dist/rsc/index.d.ts.map +1 -1
- package/dist/rsc/index.js +17 -27
- package/package.json +6 -6
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAsBlD,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,MAAM,CA+hBpE;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/api/index.js
CHANGED
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Farm.js API Routes Plugin
|
|
3
|
-
*
|
|
4
|
-
* Standalone API route support that works with or without RSC.
|
|
5
|
-
*
|
|
6
|
-
* Supports two patterns:
|
|
7
|
-
* 1. File-based routing: /src/api/hello/route.ts -> /api/hello
|
|
8
|
-
* The path is auto-inferred from file location
|
|
9
|
-
*
|
|
10
|
-
* 2. Root routes.ts file: /src/routes.ts with explicit paths
|
|
11
|
-
* createEndpoint('/api/custom', { method: 'GET' }, handler)
|
|
12
|
-
*
|
|
13
|
-
* Uses better-call's createRouter for proper Zod validation and parsing.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* import { farmApi } from '@farm.js/plugin/api'
|
|
18
|
-
*
|
|
19
|
-
* export default defineConfig({
|
|
20
|
-
* plugins: [farmApi({ srcDir: 'src' })],
|
|
21
|
-
* })
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
1
|
+
import { loadFarmDevModule } from "@farm.js/core/plugin";
|
|
24
2
|
import { _withAfterNodeMiddleware } from "@farm.js/core/after";
|
|
25
3
|
import { _runWithAPIRequestRuntime, createFarmRequestBodyErrorResponse, readNodeRequestBody, resolveFarmServerConfig, } from "@farm.js/core/internal/production-runtime";
|
|
26
4
|
import { API_ROUTE_METHODS, getAllowedAPIRouteMethods, invokeAPIRouteEndpoint, matchAPIRouteAtBasePath, resolveAPIRouteEndpoint, } from "@farm.js/core/api/runtime";
|
|
@@ -204,7 +182,7 @@ export default function farmApi(options = {}) {
|
|
|
204
182
|
try {
|
|
205
183
|
const relativePath = path.relative(apiDir, path.dirname(filePath));
|
|
206
184
|
const routePath = "/api/" + (relativePath === "." ? "" : relativePath.replace(/\\/g, "/"));
|
|
207
|
-
const routeModule = await server
|
|
185
|
+
const routeModule = await loadFarmDevModule(server, filePath);
|
|
208
186
|
const endpoints = {};
|
|
209
187
|
const availableMethods = [];
|
|
210
188
|
for (const method of API_ROUTE_METHODS) {
|
|
@@ -241,7 +219,7 @@ export default function farmApi(options = {}) {
|
|
|
241
219
|
for (const routesFile of routesFiles) {
|
|
242
220
|
if (fs.existsSync(routesFile)) {
|
|
243
221
|
try {
|
|
244
|
-
const routesModule = await server
|
|
222
|
+
const routesModule = await loadFarmDevModule(server, routesFile);
|
|
245
223
|
// Look for exported endpoints with explicit paths
|
|
246
224
|
for (const [exportName, exportValue] of Object.entries(routesModule)) {
|
|
247
225
|
// Check both object and function exports (better-call returns functions)
|
|
@@ -394,7 +372,7 @@ export default function farmApi(options = {}) {
|
|
|
394
372
|
}
|
|
395
373
|
}
|
|
396
374
|
try {
|
|
397
|
-
const routesModule = await server
|
|
375
|
+
const routesModule = await loadFarmDevModule(server, file);
|
|
398
376
|
// Look for exported endpoints with explicit paths
|
|
399
377
|
// Endpoints can be functions (from better-call) or objects
|
|
400
378
|
for (const [exportName, exportValue] of Object.entries(routesModule)) {
|
|
@@ -446,7 +424,7 @@ export default function farmApi(options = {}) {
|
|
|
446
424
|
if (routePathToUpdate) {
|
|
447
425
|
try {
|
|
448
426
|
// Reload the module
|
|
449
|
-
const routeModule = await server
|
|
427
|
+
const routeModule = await loadFarmDevModule(server, file);
|
|
450
428
|
const endpoints = {};
|
|
451
429
|
const availableMethods = [];
|
|
452
430
|
for (const method of API_ROUTE_METHODS) {
|
|
@@ -479,7 +457,7 @@ export default function farmApi(options = {}) {
|
|
|
479
457
|
const apiDir = path.join(server.config.root, srcDir, "api");
|
|
480
458
|
const relativePath = path.relative(apiDir, path.dirname(file));
|
|
481
459
|
const routePath = "/api/" + (relativePath === "." ? "" : relativePath.replace(/\\/g, "/"));
|
|
482
|
-
const routeModule = await server
|
|
460
|
+
const routeModule = await loadFarmDevModule(server, file);
|
|
483
461
|
const endpoints = {};
|
|
484
462
|
const availableMethods = [];
|
|
485
463
|
for (const method of API_ROUTE_METHODS) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"
|
|
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,CAAC,GAAG,IAAI,CAAC;AAE1B,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EACF,iBAAiB,GACjB;QAAE,KAAK,EAAE,MAAM;YAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA;SAAE,CAAC;QAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;IAC7F,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAuKD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAoUlF;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/middleware/index.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Farm.js Middleware Plugin
|
|
3
|
-
*
|
|
4
|
-
* Standalone middleware support that works with or without RSC.
|
|
5
|
-
* Discovers and executes middleware.ts files in the source directory.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { farmMiddleware } from '@farm.js/plugin/middleware'
|
|
10
|
-
*
|
|
11
|
-
* export default defineConfig({
|
|
12
|
-
* plugins: [farmMiddleware({ srcDir: 'src' })],
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
1
|
+
import { loadFarmDevModule } from "@farm.js/core/plugin";
|
|
16
2
|
import { createRequire } from "node:module";
|
|
17
3
|
import { _withAfterNodeMiddleware } from "@farm.js/core/after";
|
|
18
4
|
import { devServableFileExists } from "../dev-static.js";
|
|
@@ -222,7 +208,7 @@ export default function farmMiddleware(options = {}) {
|
|
|
222
208
|
const middlewareFile = path.join(dir, `middleware${ext}`);
|
|
223
209
|
if (fs.existsSync(middlewareFile)) {
|
|
224
210
|
try {
|
|
225
|
-
const module = await server
|
|
211
|
+
const module = await loadFarmDevModule(server, middlewareFile);
|
|
226
212
|
if (module.default) {
|
|
227
213
|
middlewareCache.set(routePath, {
|
|
228
214
|
path: routePath,
|
|
@@ -421,7 +407,7 @@ export default function farmMiddleware(options = {}) {
|
|
|
421
407
|
if (mw.filePath === file) {
|
|
422
408
|
try {
|
|
423
409
|
// Reload the module
|
|
424
|
-
const module = await server
|
|
410
|
+
const module = await loadFarmDevModule(server, file);
|
|
425
411
|
if (module.default) {
|
|
426
412
|
middlewareCache.set(routePath, {
|
|
427
413
|
path: routePath,
|
|
@@ -447,7 +433,7 @@ export default function farmMiddleware(options = {}) {
|
|
|
447
433
|
.replace(srcPath, "")
|
|
448
434
|
.replace(/\/middleware\.(ts|tsx|js|jsx)$/, "");
|
|
449
435
|
const routePath = relativePath === "" ? "/" : relativePath;
|
|
450
|
-
const module = await server
|
|
436
|
+
const module = await loadFarmDevModule(server, file);
|
|
451
437
|
if (module.default) {
|
|
452
438
|
middlewareCache.set(routePath, {
|
|
453
439
|
path: routePath,
|
package/dist/rsc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rsc/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rsc/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CA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E;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,gHAAgH;IAChH,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,aAAkB,GAAG,UAAU,CA2DnE;AAuXD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAuyC5E"}
|
package/dist/rsc/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { loadFarmDevModule, FarmDevEnvironmentError } from "@farm.js/core/plugin";
|
|
1
2
|
/**
|
|
2
3
|
* Farm.js RSC Plugin
|
|
3
4
|
*
|
|
@@ -1144,18 +1145,16 @@ if (document.readyState === 'loading') {
|
|
|
1144
1145
|
const startTime = Date.now();
|
|
1145
1146
|
try {
|
|
1146
1147
|
const clientEntryUrl = "/.farm/rsc-entries/entry.browser.tsx";
|
|
1147
|
-
const ssrEnv = server.environments
|
|
1148
|
+
const ssrEnv = server.environments.ssr;
|
|
1148
1149
|
globalThis.__VITE_RSC_LOAD_SSR__ = async () => {
|
|
1149
1150
|
if (ssrEnv) {
|
|
1150
1151
|
const ssrSource = ssrEnv.config?.build?.rollupOptions?.input?.index ??
|
|
1151
1152
|
path.join(server.config.root, ".farm/rsc-entries/entry.ssr.tsx");
|
|
1152
|
-
const resolved = await ssrEnv.pluginContainer.resolveId(ssrSource
|
|
1153
|
-
ssr: true,
|
|
1154
|
-
});
|
|
1153
|
+
const resolved = await ssrEnv.pluginContainer.resolveId(ssrSource);
|
|
1155
1154
|
if (resolved?.id)
|
|
1156
|
-
return
|
|
1155
|
+
return loadFarmDevModule(server, resolved.id);
|
|
1157
1156
|
}
|
|
1158
|
-
return server
|
|
1157
|
+
return loadFarmDevModule(server, "./.farm/rsc-entries/entry.ssr.tsx");
|
|
1159
1158
|
};
|
|
1160
1159
|
// When server actions are enabled, prepend an inline assignment so __viteRscCallServer
|
|
1161
1160
|
// is always a function before any chunk runs (avoids "globalThis.__viteRscCallServer is not a function").
|
|
@@ -1187,8 +1186,11 @@ if (document.readyState === 'loading') {
|
|
|
1187
1186
|
: undefined,
|
|
1188
1187
|
});
|
|
1189
1188
|
// Load the RSC entry in the "rsc" environment so @vitejs/plugin-rsc transforms run with this.environment.name === "rsc".
|
|
1190
|
-
//
|
|
1191
|
-
const rscEnv = server.environments
|
|
1189
|
+
// Never evaluate an RSC entry with SSR conditions or share its module cache.
|
|
1190
|
+
const rscEnv = server.environments.rsc;
|
|
1191
|
+
if (!rscEnv) {
|
|
1192
|
+
throw new FarmDevEnvironmentError('[Farm.js] The "rsc" development environment is missing. Enable @vitejs/plugin-rsc before serving RSC requests.');
|
|
1193
|
+
}
|
|
1192
1194
|
let rscEntry = null;
|
|
1193
1195
|
if (rscEnv) {
|
|
1194
1196
|
const rscSource = rscEnv.config?.build?.rollupOptions?.input?.index ??
|
|
@@ -1196,23 +1198,11 @@ if (document.readyState === 'loading') {
|
|
|
1196
1198
|
const root = server.config.root;
|
|
1197
1199
|
const importer = path.join(root, "vite.config.ts");
|
|
1198
1200
|
const absoluteRscEntry = path.resolve(root, ".farm", "rsc-entries", "entry.rsc.tsx");
|
|
1199
|
-
const resolved = (await rscEnv.pluginContainer.resolveId(rscSource, importer
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
(await rscEnv.pluginContainer.resolveId(rscSource, undefined, { ssr: true })) ??
|
|
1203
|
-
(await rscEnv.pluginContainer.resolveId(absoluteRscEntry, undefined, {
|
|
1204
|
-
ssr: true,
|
|
1205
|
-
}));
|
|
1201
|
+
const resolved = (await rscEnv.pluginContainer.resolveId(rscSource, importer)) ??
|
|
1202
|
+
(await rscEnv.pluginContainer.resolveId(rscSource)) ??
|
|
1203
|
+
(await rscEnv.pluginContainer.resolveId(absoluteRscEntry));
|
|
1206
1204
|
const id = resolved?.id ?? pathToFileURL(absoluteRscEntry).href;
|
|
1207
|
-
rscEntry = await
|
|
1208
|
-
}
|
|
1209
|
-
if (!rscEntry?.default?.fetch) {
|
|
1210
|
-
try {
|
|
1211
|
-
rscEntry = await server.ssrLoadModule("./.farm/rsc-entries/entry.rsc.tsx");
|
|
1212
|
-
}
|
|
1213
|
-
catch (_) {
|
|
1214
|
-
// Ignore; will fall through to legacy handler
|
|
1215
|
-
}
|
|
1205
|
+
rscEntry = await loadFarmDevModule(server, id, "rsc");
|
|
1216
1206
|
}
|
|
1217
1207
|
if (!rscEntry?.default?.fetch)
|
|
1218
1208
|
throw new Error("[Farm.js] Could not load RSC entry in rsc environment");
|
|
@@ -1240,7 +1230,7 @@ if (document.readyState === 'loading') {
|
|
|
1240
1230
|
return;
|
|
1241
1231
|
}
|
|
1242
1232
|
// RSC pipeline failed; fall back to legacy SSR for GET only
|
|
1243
|
-
if (method !== "GET") {
|
|
1233
|
+
if (method !== "GET" || rscError instanceof FarmDevEnvironmentError) {
|
|
1244
1234
|
const duration = Date.now() - startTime;
|
|
1245
1235
|
logResponse(method, pathname, 500, duration);
|
|
1246
1236
|
console.error("[Farm.js] RSC dev handler error:", rscError);
|
|
@@ -1288,7 +1278,7 @@ if (document.readyState === 'loading') {
|
|
|
1288
1278
|
matchedPath = pagePath;
|
|
1289
1279
|
break;
|
|
1290
1280
|
}
|
|
1291
|
-
pageModule = await server
|
|
1281
|
+
pageModule = await loadFarmDevModule(server, actualPath);
|
|
1292
1282
|
if (pageModule?.default) {
|
|
1293
1283
|
pageCache.set(pagePath, pageModule);
|
|
1294
1284
|
matchedPath = pagePath;
|
|
@@ -1305,7 +1295,7 @@ if (document.readyState === 'loading') {
|
|
|
1305
1295
|
}
|
|
1306
1296
|
try {
|
|
1307
1297
|
const layoutPath = `./${srcDir}${appSegment ? `/${appSegment}` : ""}/layout.tsx`;
|
|
1308
|
-
layoutModule = await server
|
|
1298
|
+
layoutModule = await loadFarmDevModule(server, layoutPath);
|
|
1309
1299
|
}
|
|
1310
1300
|
catch { }
|
|
1311
1301
|
const React = await import("react");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm.js/plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Official plugins for Farm.js framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Farm.js Team",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"nitro": "3.0.260903-beta",
|
|
63
63
|
"picocolors": "^1.0.0",
|
|
64
64
|
"rsc-html-stream": "^0.0.4",
|
|
65
|
-
"@farm.js/core": "0.1.
|
|
65
|
+
"@farm.js/core": "0.1.20"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@types/node": "^20.
|
|
68
|
+
"@types/node": "^22.20.5",
|
|
69
69
|
"@types/react": "^19.0.0",
|
|
70
70
|
"@types/react-dom": "^19.0.0",
|
|
71
71
|
"@vitejs/plugin-rsc": "0.5.32",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"react-server-dom-webpack": "19.2.8",
|
|
75
75
|
"tsdown": "^0.15.7",
|
|
76
76
|
"typescript": "^5.5.3",
|
|
77
|
-
"vite": "
|
|
78
|
-
"vitest": "
|
|
77
|
+
"vite": "8.3.4",
|
|
78
|
+
"vitest": "5.0.5"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@vitejs/plugin-rsc": "0.5.32",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react-dom": "19.2.8",
|
|
84
84
|
"react-server-dom-webpack": "19.2.8",
|
|
85
85
|
"vite": ">=6.0.0",
|
|
86
|
-
"@farm.js/core": "0.1.
|
|
86
|
+
"@farm.js/core": "0.1.20"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@vitejs/plugin-rsc": {
|