@kubb/plugin-fetch 5.5.1 → 5.6.0-canary.20260924T112635

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.js CHANGED
@@ -5,6 +5,7 @@ import { createFunctionParameter, createFunctionParameters, functionPrinter, plu
5
5
  import { File, Function, jsxRenderer } from "kubb/jsx";
6
6
  import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
7
7
  import { pluginZodName } from "@kubb/plugin-zod";
8
+ import { readFileSync } from "node:fs";
8
9
  import { fileURLToPath } from "node:url";
9
10
  //#region ../../internals/shared/src/params.ts
10
11
  /**
@@ -1394,6 +1395,27 @@ const resolverClient = createResolver({
1394
1395
  }
1395
1396
  });
1396
1397
  //#endregion
1398
+ //#region ../../internals/client/src/runtimeTemplate.ts
1399
+ /** Apply the active TypeScript parser's import extension to a copied client runtime. */
1400
+ function runtimeTemplate(path, config) {
1401
+ const parser = config.parsers.find((item) => item.extNames?.includes(".ts"));
1402
+ const probe = ast.factory.createFile({
1403
+ baseName: "probe.ts",
1404
+ path: "probe.ts",
1405
+ imports: [ast.factory.createImport({
1406
+ name: ["KubbRuntimeImport"],
1407
+ path: "/probeDependency.ts",
1408
+ root: "/"
1409
+ })],
1410
+ sources: [ast.factory.createSource({
1411
+ name: "probe",
1412
+ nodes: [ast.factory.createText("KubbRuntimeImport")]
1413
+ })]
1414
+ });
1415
+ const extension = parser?.parse(probe).match(/from ['"]\.\/probeDependency(\.[^'"]+)?['"]/)?.[1] ?? "";
1416
+ return readFileSync(path, "utf8").replace(/(from ['"]\.\/(?:serializers|standardSchema))(?:\.ts|\.js)?(['"])/g, `$1${extension}$2`);
1417
+ }
1418
+ //#endregion
1397
1419
  //#region src/generators/clientGenerator.tsx
1398
1420
  /**
1399
1421
  * Built-in operation generator for `@kubb/plugin-fetch`. Emits one async function per OpenAPI
@@ -1482,7 +1504,7 @@ const pluginFetch = definePlugin((options) => {
1482
1504
  ctx.injectFile({
1483
1505
  baseName: "client.ts",
1484
1506
  path: path.resolve(root, ".kubb/client.ts"),
1485
- copy: fetchClientTemplatePath,
1507
+ banner: runtimeTemplate(fetchClientTemplatePath, ctx.config),
1486
1508
  footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
1487
1509
  });
1488
1510
  ctx.injectFile({