@farm.js/plugin 0.1.22 → 0.1.24

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.22";
42
+ export declare const version = "0.1.24";
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.22";
42
+ export const version = "0.1.24";
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":"middleware-config-module.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware-config-module.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AASF,KAAK,gBAAgB,GACjB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA4P5C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACf,gBAAgB,CA+IlB;AAiBD,wBAAsB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAejG"}
1
+ {"version":3,"file":"middleware-config-module.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware-config-module.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AASF,KAAK,gBAAgB,GACjB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA4P5C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACf,gBAAgB,CA+IlB;AAiBD,wBAAsB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsBjG"}
@@ -361,7 +361,7 @@ export function extractRscMiddlewareConfigModule(source, program) {
361
361
  code: `${declarations.join("\n")}${declarations.length ? "\n" : ""}export default { middleware: ${middlewareSource} };\n`,
362
362
  };
363
363
  }
364
- function esbuildLoader(file) {
364
+ function sourceLang(file) {
365
365
  switch (path.extname(file)) {
366
366
  case ".ts":
367
367
  case ".mts":
@@ -376,15 +376,21 @@ function esbuildLoader(file) {
376
376
  }
377
377
  }
378
378
  export async function loadRscMiddlewareConfigModule(configPath) {
379
- const [{ readFile }, { parseAst, transformWithEsbuild }] = await Promise.all([
380
- import("node:fs/promises"),
381
- import("vite"),
382
- ]);
379
+ const [{ readFile }, vite] = await Promise.all([import("node:fs/promises"), import("vite")]);
383
380
  const source = await readFile(configPath, "utf8");
384
- const transformed = await transformWithEsbuild(source, configPath, {
385
- format: "esm",
386
- jsx: "automatic",
387
- loader: esbuildLoader(configPath),
388
- });
389
- return extractRscMiddlewareConfigModule(transformed.code, parseAst(transformed.code));
381
+ const lang = sourceLang(configPath);
382
+ // Vite 8 transforms with Oxc and only reaches esbuild when the app installs it.
383
+ // Vite 6 and 7 have no transformWithOxc and always ship esbuild.
384
+ const transformed = typeof vite.transformWithOxc === "function"
385
+ ? await vite.transformWithOxc(source, configPath, {
386
+ lang,
387
+ sourceType: "module",
388
+ jsx: { runtime: "automatic" },
389
+ })
390
+ : await vite.transformWithEsbuild(source, configPath, {
391
+ format: "esm",
392
+ jsx: "automatic",
393
+ loader: lang,
394
+ });
395
+ return extractRscMiddlewareConfigModule(transformed.code, vite.parseAst(transformed.code));
390
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/plugin",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Official plugins for Farm.js framework",
5
5
  "license": "MIT",
6
6
  "author": "Farm.js Team",
@@ -62,7 +62,7 @@
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.22"
65
+ "@farm.js/core": "0.1.24"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^22.20.5",
@@ -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.22"
86
+ "@farm.js/core": "0.1.24"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@vitejs/plugin-rsc": {