@farm.js/core 0.1.0-beta.50 → 0.1.0-beta.52
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/{chunk-HSHA3H3U.mjs → chunk-3E2WRUR2.mjs} +15 -1
- package/dist/chunk-3E2WRUR2.mjs.map +1 -0
- package/dist/{chunk-6YIZDTX7.mjs → chunk-BTFOMBWK.mjs} +43 -5
- package/dist/chunk-BTFOMBWK.mjs.map +1 -0
- package/dist/{chunk-GM43ZLTS.mjs → chunk-JK6YAQ3E.mjs} +52 -9
- package/dist/chunk-JK6YAQ3E.mjs.map +1 -0
- package/dist/{chunk-ZAW3D2TI.mjs → chunk-M2DI67UZ.mjs} +2 -2
- package/dist/{chunk-DDE3BBDN.mjs → chunk-TW74WBSB.mjs} +2 -2
- package/dist/{chunk-DDE3BBDN.mjs.map → chunk-TW74WBSB.mjs.map} +1 -1
- package/dist/{chunk-QTAJIJJJ.mjs → chunk-XMUPYG2D.mjs} +2 -2
- package/dist/client/lifecycle.mjs +2 -2
- package/dist/client-plugins.cjs +1 -1
- package/dist/client-plugins.cjs.map +1 -1
- package/dist/client-plugins.mjs +2 -2
- package/dist/client.cjs +15 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +4 -4
- package/dist/index.cjs +113 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/internal/build-runtime.cjs +99 -11
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.mjs +3 -3
- package/dist/internal/client-runtime.cjs +1 -1
- package/dist/internal/client-runtime.cjs.map +1 -1
- package/dist/internal/client-runtime.mjs +2 -2
- package/dist/plugin.cjs +51 -8
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +2 -2
- package/dist/renderer-client.cjs +14 -0
- package/dist/renderer-client.cjs.map +1 -1
- package/dist/renderer-client.mjs +1 -1
- package/dist/server-query-client.cjs +14 -0
- package/dist/server-query-client.cjs.map +1 -1
- package/dist/server-query-client.mjs +2 -2
- package/dist/server.cjs +51 -8
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +51 -8
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-6YIZDTX7.mjs.map +0 -1
- package/dist/chunk-GM43ZLTS.mjs.map +0 -1
- package/dist/chunk-HSHA3H3U.mjs.map +0 -1
- /package/dist/{chunk-ZAW3D2TI.mjs.map → chunk-M2DI67UZ.mjs.map} +0 -0
- /package/dist/{chunk-QTAJIJJJ.mjs.map → chunk-XMUPYG2D.mjs.map} +0 -0
|
@@ -227,7 +227,7 @@ import {
|
|
|
227
227
|
} from "./chunk-7ZMKVETU.mjs";
|
|
228
228
|
import {
|
|
229
229
|
FARM_VERSION
|
|
230
|
-
} from "./chunk-
|
|
230
|
+
} from "./chunk-TW74WBSB.mjs";
|
|
231
231
|
import {
|
|
232
232
|
__name,
|
|
233
233
|
__require
|
|
@@ -6858,6 +6858,14 @@ import { pathToFileURL as pathToFileURL3 } from "url";
|
|
|
6858
6858
|
// src/dev-static.ts
|
|
6859
6859
|
import * as fs6 from "fs";
|
|
6860
6860
|
import * as path11 from "path";
|
|
6861
|
+
function shouldBypassFarmRouterForDottedPath(pathname, routeManager, baseDirs) {
|
|
6862
|
+
if (!pathname.includes(".") || pathname.endsWith(".html")) return false;
|
|
6863
|
+
const matchesAppRoute = Boolean(
|
|
6864
|
+
routeManager?.matchRoute(pathname)?.route || routeManager?.matchMetadataRoute(pathname) || routeManager?.matchMetadataImage(pathname)
|
|
6865
|
+
);
|
|
6866
|
+
return !matchesAppRoute || devServableFileExists(pathname, baseDirs);
|
|
6867
|
+
}
|
|
6868
|
+
__name(shouldBypassFarmRouterForDottedPath, "shouldBypassFarmRouterForDottedPath");
|
|
6861
6869
|
function devServableFileExists(pathname, baseDirs) {
|
|
6862
6870
|
let decodedPathname;
|
|
6863
6871
|
try {
|
|
@@ -6883,6 +6891,34 @@ function devServableFileExists(pathname, baseDirs) {
|
|
|
6883
6891
|
}
|
|
6884
6892
|
__name(devServableFileExists, "devServableFileExists");
|
|
6885
6893
|
|
|
6894
|
+
// src/server-query-boundary.ts
|
|
6895
|
+
var SERVER_FN_FACTORIES = ["createServerQuery", "createServerFn"];
|
|
6896
|
+
var FARM_CORE_IMPORT_RE = /import\s*(?!type\b)(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*(["'])@farm\.js\/core(?:\/[\w./-]+)?\2/g;
|
|
6897
|
+
function findClientServerFnViolation(code, id) {
|
|
6898
|
+
if (id.startsWith("\0") || id.startsWith("virtual:") || id.includes("node_modules")) return null;
|
|
6899
|
+
if (!code.includes("@farm.js/core")) return null;
|
|
6900
|
+
for (const match of code.matchAll(FARM_CORE_IMPORT_RE)) {
|
|
6901
|
+
const specifiers = match[1];
|
|
6902
|
+
for (const factory of SERVER_FN_FACTORIES) {
|
|
6903
|
+
if (!new RegExp(`(?:^|[\\s{,])${factory}(?:[\\s},]|$)`).test(specifiers)) continue;
|
|
6904
|
+
if (new RegExp(`(?<![\\w$.])${factory}\\s*(?:<[^>]*>)?\\s*\\(`).test(code)) {
|
|
6905
|
+
return { factory };
|
|
6906
|
+
}
|
|
6907
|
+
}
|
|
6908
|
+
}
|
|
6909
|
+
return null;
|
|
6910
|
+
}
|
|
6911
|
+
__name(findClientServerFnViolation, "findClientServerFnViolation");
|
|
6912
|
+
function formatServerFnBoundaryError(violation, id) {
|
|
6913
|
+
return [
|
|
6914
|
+
`${violation.factory} handlers run only on the server, but ${id} is being bundled into the client.`,
|
|
6915
|
+
`Importing a ${violation.factory} module from client code executes the server handler (and its Node-only imports) in the browser.`,
|
|
6916
|
+
`Either enable the server-function transform (add @farm.js/plugin/rsc and set experimental.serverActions: true in farm.config.ts) so client imports become server references,`,
|
|
6917
|
+
`or keep the query on the server: call it from server components, or expose an API route and use createAPIClient from the client.`
|
|
6918
|
+
].join("\n");
|
|
6919
|
+
}
|
|
6920
|
+
__name(formatServerFnBoundaryError, "formatServerFnBoundaryError");
|
|
6921
|
+
|
|
6886
6922
|
// src/image-vite.ts
|
|
6887
6923
|
import { readFile as readFile4 } from "fs/promises";
|
|
6888
6924
|
import path12 from "path";
|
|
@@ -8427,13 +8463,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
8427
8463
|
if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")) {
|
|
8428
8464
|
return next();
|
|
8429
8465
|
}
|
|
8430
|
-
if (requestPathname
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
return next();
|
|
8436
|
-
}
|
|
8466
|
+
if (shouldBypassFarmRouterForDottedPath(requestPathname, farmApp?.getRouteManager(), [
|
|
8467
|
+
server.config.publicDir,
|
|
8468
|
+
server.config.root
|
|
8469
|
+
])) {
|
|
8470
|
+
return next();
|
|
8437
8471
|
}
|
|
8438
8472
|
if (req.url?.startsWith("/__farm/page-data")) {
|
|
8439
8473
|
const urlObj = new URL(req.url, `http://${req.headers.host || "localhost:3000"}`);
|
|
@@ -9087,6 +9121,15 @@ export const manifest = getManifest();
|
|
|
9087
9121
|
}
|
|
9088
9122
|
},
|
|
9089
9123
|
async transform(code, id, transformOptions) {
|
|
9124
|
+
if (!transformOptions?.ssr) {
|
|
9125
|
+
const currentConfig = farmApp?.getConfig() ?? options;
|
|
9126
|
+
if (currentConfig.experimental?.serverActions !== true) {
|
|
9127
|
+
const violation = findClientServerFnViolation(code, id);
|
|
9128
|
+
if (violation) {
|
|
9129
|
+
this.error(formatServerFnBoundaryError(violation, id));
|
|
9130
|
+
}
|
|
9131
|
+
}
|
|
9132
|
+
}
|
|
9090
9133
|
if (typeof imageImports.transform === "function") {
|
|
9091
9134
|
const imageModule = await imageImports.transform.call(this, code, id, transformOptions);
|
|
9092
9135
|
if (imageModule) return imageModule;
|
|
@@ -11328,4 +11371,4 @@ export {
|
|
|
11328
11371
|
farmPlugin,
|
|
11329
11372
|
defineConfig
|
|
11330
11373
|
};
|
|
11331
|
-
//# sourceMappingURL=chunk-
|
|
11374
|
+
//# sourceMappingURL=chunk-JK6YAQ3E.mjs.map
|