@farm.js/core 0.1.0-beta.51 → 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-235ZOXDY.mjs → chunk-BTFOMBWK.mjs} +2 -2
- package/dist/{chunk-QCSOE6HT.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-7XJV5RZO.mjs → chunk-TW74WBSB.mjs} +2 -2
- package/dist/{chunk-7XJV5RZO.mjs.map → chunk-TW74WBSB.mjs.map} +1 -1
- package/dist/{chunk-FRN7PNL4.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 +72 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/internal/build-runtime.cjs +58 -8
- 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-HSHA3H3U.mjs.map +0 -1
- package/dist/chunk-QCSOE6HT.mjs.map +0 -1
- /package/dist/{chunk-235ZOXDY.mjs.map → chunk-BTFOMBWK.mjs.map} +0 -0
- /package/dist/{chunk-ZAW3D2TI.mjs.map → chunk-M2DI67UZ.mjs.map} +0 -0
- /package/dist/{chunk-FRN7PNL4.mjs.map → chunk-XMUPYG2D.mjs.map} +0 -0
package/dist/server.cjs
CHANGED
|
@@ -21251,7 +21251,7 @@ _setFarmThemeServerSnapshotResolver(() => {
|
|
|
21251
21251
|
});
|
|
21252
21252
|
|
|
21253
21253
|
// package.json
|
|
21254
|
-
var version = "0.1.0-beta.
|
|
21254
|
+
var version = "0.1.0-beta.52";
|
|
21255
21255
|
|
|
21256
21256
|
// src/version.ts
|
|
21257
21257
|
var FARM_VERSION = version;
|
|
@@ -26293,6 +26293,14 @@ __name(_withAfterNodeMiddleware, "_withAfterNodeMiddleware");
|
|
|
26293
26293
|
// src/dev-static.ts
|
|
26294
26294
|
var fs9 = __toESM(require("fs"));
|
|
26295
26295
|
var path20 = __toESM(require("path"));
|
|
26296
|
+
function shouldBypassFarmRouterForDottedPath(pathname, routeManager, baseDirs) {
|
|
26297
|
+
if (!pathname.includes(".") || pathname.endsWith(".html")) return false;
|
|
26298
|
+
const matchesAppRoute = Boolean(
|
|
26299
|
+
routeManager?.matchRoute(pathname)?.route || routeManager?.matchMetadataRoute(pathname) || routeManager?.matchMetadataImage(pathname)
|
|
26300
|
+
);
|
|
26301
|
+
return !matchesAppRoute || devServableFileExists(pathname, baseDirs);
|
|
26302
|
+
}
|
|
26303
|
+
__name(shouldBypassFarmRouterForDottedPath, "shouldBypassFarmRouterForDottedPath");
|
|
26296
26304
|
function devServableFileExists(pathname, baseDirs) {
|
|
26297
26305
|
let decodedPathname;
|
|
26298
26306
|
try {
|
|
@@ -26318,6 +26326,34 @@ function devServableFileExists(pathname, baseDirs) {
|
|
|
26318
26326
|
}
|
|
26319
26327
|
__name(devServableFileExists, "devServableFileExists");
|
|
26320
26328
|
|
|
26329
|
+
// src/server-query-boundary.ts
|
|
26330
|
+
var SERVER_FN_FACTORIES = ["createServerQuery", "createServerFn"];
|
|
26331
|
+
var FARM_CORE_IMPORT_RE = /import\s*(?!type\b)(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*(["'])@farm\.js\/core(?:\/[\w./-]+)?\2/g;
|
|
26332
|
+
function findClientServerFnViolation(code, id) {
|
|
26333
|
+
if (id.startsWith("\0") || id.startsWith("virtual:") || id.includes("node_modules")) return null;
|
|
26334
|
+
if (!code.includes("@farm.js/core")) return null;
|
|
26335
|
+
for (const match of code.matchAll(FARM_CORE_IMPORT_RE)) {
|
|
26336
|
+
const specifiers = match[1];
|
|
26337
|
+
for (const factory of SERVER_FN_FACTORIES) {
|
|
26338
|
+
if (!new RegExp(`(?:^|[\\s{,])${factory}(?:[\\s},]|$)`).test(specifiers)) continue;
|
|
26339
|
+
if (new RegExp(`(?<![\\w$.])${factory}\\s*(?:<[^>]*>)?\\s*\\(`).test(code)) {
|
|
26340
|
+
return { factory };
|
|
26341
|
+
}
|
|
26342
|
+
}
|
|
26343
|
+
}
|
|
26344
|
+
return null;
|
|
26345
|
+
}
|
|
26346
|
+
__name(findClientServerFnViolation, "findClientServerFnViolation");
|
|
26347
|
+
function formatServerFnBoundaryError(violation, id) {
|
|
26348
|
+
return [
|
|
26349
|
+
`${violation.factory} handlers run only on the server, but ${id} is being bundled into the client.`,
|
|
26350
|
+
`Importing a ${violation.factory} module from client code executes the server handler (and its Node-only imports) in the browser.`,
|
|
26351
|
+
`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,`,
|
|
26352
|
+
`or keep the query on the server: call it from server components, or expose an API route and use createAPIClient from the client.`
|
|
26353
|
+
].join("\n");
|
|
26354
|
+
}
|
|
26355
|
+
__name(formatServerFnBoundaryError, "formatServerFnBoundaryError");
|
|
26356
|
+
|
|
26321
26357
|
// src/vite.ts
|
|
26322
26358
|
init_deployment();
|
|
26323
26359
|
init_image_config();
|
|
@@ -27889,13 +27925,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
27889
27925
|
if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")) {
|
|
27890
27926
|
return next();
|
|
27891
27927
|
}
|
|
27892
|
-
if (requestPathname
|
|
27893
|
-
|
|
27894
|
-
|
|
27895
|
-
|
|
27896
|
-
|
|
27897
|
-
return next();
|
|
27898
|
-
}
|
|
27928
|
+
if (shouldBypassFarmRouterForDottedPath(requestPathname, farmApp?.getRouteManager(), [
|
|
27929
|
+
server.config.publicDir,
|
|
27930
|
+
server.config.root
|
|
27931
|
+
])) {
|
|
27932
|
+
return next();
|
|
27899
27933
|
}
|
|
27900
27934
|
if (req.url?.startsWith("/__farm/page-data")) {
|
|
27901
27935
|
const urlObj = new URL(req.url, `http://${req.headers.host || "localhost:3000"}`);
|
|
@@ -28549,6 +28583,15 @@ export const manifest = getManifest();
|
|
|
28549
28583
|
}
|
|
28550
28584
|
},
|
|
28551
28585
|
async transform(code, id, transformOptions) {
|
|
28586
|
+
if (!transformOptions?.ssr) {
|
|
28587
|
+
const currentConfig = farmApp?.getConfig() ?? options;
|
|
28588
|
+
if (currentConfig.experimental?.serverActions !== true) {
|
|
28589
|
+
const violation = findClientServerFnViolation(code, id);
|
|
28590
|
+
if (violation) {
|
|
28591
|
+
this.error(formatServerFnBoundaryError(violation, id));
|
|
28592
|
+
}
|
|
28593
|
+
}
|
|
28594
|
+
}
|
|
28552
28595
|
if (typeof imageImports.transform === "function") {
|
|
28553
28596
|
const imageModule = await imageImports.transform.call(this, code, id, transformOptions);
|
|
28554
28597
|
if (imageModule) return imageModule;
|