@farm.js/plugin 0.1.44 → 0.1.46

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/index.d.ts CHANGED
@@ -39,5 +39,5 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export declare const version = "0.1.44";
42
+ export declare const version = "0.1.46";
43
43
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export const version = "0.1.44";
42
+ export const version = "0.1.46";
43
43
  // Note: Import plugins from their respective subpaths:
44
44
  // - @farm.js/plugin/rsc
45
45
  // - @farm.js/plugin/middleware
@@ -1 +1 @@
1
- {"version":3,"file":"nitro-build.d.ts","sourceRoot":"","sources":["../../src/rsc/nitro-build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6BH;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,IAAI,CAKN;AAcD,gBAAgB;AAChB,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAqCrF;AA4ED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,OAAO,CAAC,IAAI,CAAC,CAgCf;AA8FD,MAAM,MAAM,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MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA+MF,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuIhF"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import path from "path";
7
7
  import { createRequire } from "node:module";
8
- import { writeFileSync, readFileSync, mkdirSync, copyFileSync, existsSync, readdirSync, rmSync, statSync, } from "fs";
8
+ import { writeFileSync, readFileSync, mkdirSync, copyFileSync, existsSync, readdirSync, lstatSync, rmSync, statSync, symlinkSync, } from "fs";
9
9
  import { FARM_NODE_ENV_MODULE_FILE, FARM_NODE_ENV_MODULE_SOURCE, } from "@farm.js/core/internal/production-node-env";
10
10
  import { resolveRscBuildOutputPath } from "./build-paths.js";
11
11
  const MANIFEST_FILENAME = "__vite_rsc_assets_manifest.js";
@@ -106,6 +106,36 @@ function detectBundledRscRuntimes(rendererPath) {
106
106
  }
107
107
  return packages;
108
108
  }
109
+ /**
110
+ * The prerender server runs the Vite output in place, before the runtime packages are copied next
111
+ * to the server output, and a strict install (pnpm) does not expose a package the plugin depends
112
+ * on from the app root. Links them where the Vite output resolves from; returns the cleanup.
113
+ */
114
+ function linkRuntimePackages(viteDistDir, packages) {
115
+ const nodeModules = path.join(viteDistDir, "node_modules");
116
+ const ownsNodeModules = !existsSync(nodeModules);
117
+ const links = [];
118
+ for (const [packageName, packageRoot] of packages) {
119
+ const link = path.join(nodeModules, ...packageName.split("/"));
120
+ try {
121
+ lstatSync(link);
122
+ continue;
123
+ }
124
+ catch { }
125
+ mkdirSync(path.dirname(link), { recursive: true });
126
+ // A junction needs no privileges on Windows; elsewhere the type is ignored.
127
+ symlinkSync(packageRoot, link, "junction");
128
+ links.push(link);
129
+ }
130
+ return () => {
131
+ // Removes the links, never what they point at.
132
+ if (ownsNodeModules)
133
+ rmSync(nodeModules, { recursive: true, force: true });
134
+ else
135
+ for (const link of links)
136
+ rmSync(link, { force: true });
137
+ };
138
+ }
109
139
  function copyRuntimePackages(serverDir, packages) {
110
140
  if (packages.size === 0)
111
141
  return;
@@ -553,7 +583,14 @@ export async function buildRscNitro(options) {
553
583
  const serverDir = nitro.options.output.serverDir;
554
584
  await prepare(nitro);
555
585
  await copyPublicAssets(nitro);
556
- await prerenderRscPages(nitro, prerender, path.dirname(path.dirname(path.resolve(rendererPath))));
586
+ const viteDistDir = path.dirname(path.dirname(path.resolve(rendererPath)));
587
+ const unlinkRuntimePackages = linkRuntimePackages(viteDistDir, registeredRuntimePackages);
588
+ try {
589
+ await prerenderRscPages(nitro, prerender, viteDistDir);
590
+ }
591
+ finally {
592
+ unlinkRuntimePackages();
593
+ }
557
594
  await build(nitro);
558
595
  await nitro.close();
559
596
  copyRuntimePackages(serverDir, registeredRuntimePackages);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/plugin",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "Official plugins for Farm.js framework",
5
5
  "license": "MIT",
6
6
  "author": "Farm.js Team",
@@ -63,7 +63,7 @@
63
63
  "nitro": "3.0.260903-beta",
64
64
  "picocolors": "^1.0.0",
65
65
  "rsc-html-stream": "^0.0.4",
66
- "@farm.js/core": "0.1.44"
66
+ "@farm.js/core": "0.1.46"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/node": "^22.20.5",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "19.2.8",
85
85
  "react-server-dom-webpack": "19.2.8",
86
86
  "vite": ">=6.0.0",
87
- "@farm.js/core": "0.1.44"
87
+ "@farm.js/core": "0.1.46"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
90
  "@vitejs/plugin-rsc": {