Skip to content

Commit

Permalink
fix: bundle require
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Mar 6, 2024
1 parent 1ff5e6f commit bca653b
Show file tree
Hide file tree
Showing 105 changed files with 2,516 additions and 2,408 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-geese-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kubb/cli": patch
---

correct import with bundle-require
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"dependencies": {
"@vercel/analytics": "^1.2.2",
"sitemap": "^7.1.1",
"vitepress": "^1.0.0-rc.44",
"vitepress": "^1.0.0-rc.45",
"vue": "^3.4.21"
},
"devDependencies": {
"@types/node": "^20.11.24"
"@types/node": "^20.11.25"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
8 changes: 4 additions & 4 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"@kubb/swagger-ts": "workspace:*",
"@kubb/swagger-zod": "workspace:*",
"@kubb/swagger-zodios": "workspace:*",
"@tanstack/react-query": "^5.24.8",
"@tanstack/solid-query": "^5.24.8",
"@tanstack/svelte-query": "^5.24.8",
"@tanstack/vue-query": "^5.24.8",
"@tanstack/react-query": "^5.25.0",
"@tanstack/solid-query": "^5.25.0",
"@tanstack/svelte-query": "^5.25.0",
"@tanstack/vue-query": "^5.25.0",
"@zodios/core": "^10.9.6",
"axios": "^1.6.7",
"msw": "^1.3.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@kubb/ts-config": "workspace:*",
"react": "^18.2.0",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions examples/client/templates/client/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { File, Function } from '@kubb/react'
import { Editor, File, Function } from '@kubb/react'
import { Client } from '@kubb/swagger-client/components'
import React from 'react'

Expand All @@ -7,12 +7,12 @@ export const templates = {
const clientParams = [client.path.template, client.withData ? 'data' : undefined, 'options'].filter(Boolean).join(', ')

return (
<>
<Editor language="typescript">
<File.Import name="axios" path="axios" />
<Function name={name} async export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>
{`return axios.${client.method}(${clientParams})`}
</Function>
</>
</Editor>
)
},
} as const
2 changes: 1 addition & 1 deletion examples/faker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"devDependencies": {
"@kubb/ts-config": "workspace:*",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
29 changes: 14 additions & 15 deletions examples/python/kubb.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import { definePlugin as createSwaggerClient } from '@kubb/swagger-client'

import { templates } from './templates/CustomClientTemplate'
import * as client from './templates/client/index'

export default defineConfig(async () => {
return {
Expand All @@ -17,21 +19,18 @@ export default defineConfig(async () => {
// done: ['npx eslint --fix ./src/gen', 'prettier --write "**/*.{ts,tsx}"', 'pnpm typecheck'],
},
plugins: [
['@kubb/swagger', { output: false, validate: true }],
[
'@kubb/swagger-client',
{
output: {
path: './',
exportType: false,
},
group: { type: 'tag', output: './{{tag}}Service' },
templates: {
client: templates,
operations: false,
},
createSwagger({ output: false, validate: true }),
createSwaggerClient({
output: {
path: './',
exportType: false,
},
],
group: { type: 'tag', output: './{{tag}}Service' },
templates: {
client: client.templates,
operations: false,
},
}),
],
}
})
9 changes: 6 additions & 3 deletions examples/python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
"@kubb/swagger": "workspace:*",
"@kubb/swagger-client": "workspace:*",
"@kubb/swagger-ts": "workspace:*",
"axios": "^1.6.7"
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@kubb/ts-config": "workspace:*",
"react": "^18.2.0",
"@types/react": "^18.2.63",
"@types/react-dom": "^18.2.20",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions examples/python/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"target": "ES2020",
/* If NOT transpiling with TypeScript: */
"module": "ES2020",
"moduleResolution": "Bundler",
"moduleResolution": "node",
"sourceMap": true,
"strictNullChecks": true,
"jsx": "react-jsx",
Expand All @@ -18,7 +18,8 @@
"noEmit": true
},
"include": [
"./src/**/*"
"./src/**/*",
"./templates/**/*"
],
"exclude": [
"**/node_modules",
Expand Down
6 changes: 3 additions & 3 deletions examples/react-query-v5/kubb.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from '@kubb/core'
import { definePlugin as createSwagger } from '@kubb/swagger'
import { definePlugin as createSwaggerTanstackQuery } from '@kubb/swagger-tanstack-query'
import { definePlugin as createSwaggerTS } from '@kubb/swagger-ts'
import createSwagger from '@kubb/swagger'
import createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'
import createSwaggerTS from '@kubb/swagger-ts'

import * as queryKey from './templates/queryKey/index'

Expand Down
10 changes: 5 additions & 5 deletions examples/react-query-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@
"@kubb/swagger-client": "workspace:*",
"@kubb/swagger-tanstack-query": "workspace:*",
"@kubb/swagger-ts": "workspace:*",
"@tanstack/react-query": "^5.24.8",
"@tanstack/react-query": "^5.25.0",
"@tanstack/react-query-devtools": "5.0.0",
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tsup": "^8.0.2"
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.62",
"@types/react-dom": "^18.2.19",
"@types/react": "^18.2.63",
"@types/react-dom": "^18.2.20",
"@vitejs/plugin-react": "^4.2.1",
"msw": "^1.3.2",
"tsup": "^8.0.2",
"typescript": "~5.2.2",
"unplugin-kubb": "workspace:*",
"vite": "^4.5.2"
Expand Down
40 changes: 20 additions & 20 deletions examples/react-query-v5/src/gen/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export * from './useAddPetHook'
export * from './useCreateUserHook'
export * from './useCreateUsersWithListInputHook'
export * from './useDeleteOrderHook'
export * from './useDeletePetHook'
export * from './useDeleteUserHook'
export * from './useFindPetsByStatusHook'
export * from './useFindPetsByTagsHook'
export * from './useGetInventoryHook'
export * from './useGetOrderByIdHook'
export * from './useGetPetByIdHook'
export * from './useGetUserByNameHook'
export * from './useLoginUserHook'
export * from './useLogoutUserHook'
export * from './usePlaceOrderHook'
export * from './usePlaceOrderPatchHook'
export * from './useUpdatePetHook'
export * from './useUpdatePetWithFormHook'
export * from './useUpdateUserHook'
export * from './useUploadFileHook'
export * from "./useAddPetHook";
export * from "./useCreateUserHook";
export * from "./useCreateUsersWithListInputHook";
export * from "./useDeleteOrderHook";
export * from "./useDeletePetHook";
export * from "./useDeleteUserHook";
export * from "./useFindPetsByStatusHook";
export * from "./useFindPetsByTagsHook";
export * from "./useGetInventoryHook";
export * from "./useGetOrderByIdHook";
export * from "./useGetPetByIdHook";
export * from "./useGetUserByNameHook";
export * from "./useLoginUserHook";
export * from "./useLogoutUserHook";
export * from "./usePlaceOrderHook";
export * from "./usePlaceOrderPatchHook";
export * from "./useUpdatePetHook";
export * from "./useUpdatePetWithFormHook";
export * from "./useUpdateUserHook";
export * from "./useUploadFileHook";
72 changes: 36 additions & 36 deletions examples/react-query-v5/src/gen/hooks/useAddPetHook.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import client from '@kubb/swagger-client/client'
import { useMutation } from '@tanstack/react-query'
import type { AddPetMutationRequest, AddPetMutationResponse, AddPet405 } from '../models/AddPet'
import type { UseMutationOptions } from '@tanstack/react-query'
import client from "@kubb/swagger-client/client";
import { useMutation } from "@tanstack/react-query";
import type { AddPetMutationRequest, AddPetMutationResponse, AddPet405 } from "../models/AddPet";
import type { UseMutationOptions } from "@tanstack/react-query";

type AddPetClient = typeof client<AddPetMutationResponse, AddPet405, AddPetMutationRequest>
type AddPetClient = typeof client<AddPetMutationResponse, AddPet405, AddPetMutationRequest>;
type AddPet = {
data: AddPetMutationResponse
error: AddPet405
request: AddPetMutationRequest
pathParams: never
queryParams: never
headerParams: never
response: AddPetMutationResponse
client: {
parameters: Partial<Parameters<AddPetClient>[0]>
return: Awaited<ReturnType<AddPetClient>>
}
}
data: AddPetMutationResponse;
error: AddPet405;
request: AddPetMutationRequest;
pathParams: never;
queryParams: never;
headerParams: never;
response: AddPetMutationResponse;
client: {
parameters: Partial<Parameters<AddPetClient>[0]>;
return: Awaited<ReturnType<AddPetClient>>;
};
};
/**
* @description Add a new pet to the store
* @summary Add a new pet to the store
* @link /pet */
* @description Add a new pet to the store
* @summary Add a new pet to the store
* @link /pet */
export function useAddPetHook(options: {
mutation?: UseMutationOptions<AddPet['response'], AddPet['error'], AddPet['request']>
client?: AddPet['client']['parameters']
mutation?: UseMutationOptions<AddPet["response"], AddPet["error"], AddPet["request"]>;
client?: AddPet["client"]["parameters"];
} = {}) {
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
return useMutation({
mutationFn: async (data) => {
const res = await client<AddPet['data'], AddPet['error'], AddPet['request']>({
method: 'post',
url: `/pet`,
data,
...clientOptions,
})
return res.data
},
...mutationOptions,
})
}
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {};
return useMutation({
mutationFn: async (data) => {
const res = await client<AddPet["data"], AddPet["error"], AddPet["request"]>({
method: "post",
url: `/pet`,
data,
...clientOptions
});
return res.data;
},
...mutationOptions
});
}
72 changes: 36 additions & 36 deletions examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import client from '@kubb/swagger-client/client'
import { useMutation } from '@tanstack/react-query'
import type { CreateUserMutationRequest, CreateUserMutationResponse } from '../models/CreateUser'
import type { UseMutationOptions } from '@tanstack/react-query'
import client from "@kubb/swagger-client/client";
import { useMutation } from "@tanstack/react-query";
import type { CreateUserMutationRequest, CreateUserMutationResponse } from "../models/CreateUser";
import type { UseMutationOptions } from "@tanstack/react-query";

type CreateUserClient = typeof client<CreateUserMutationResponse, never, CreateUserMutationRequest>
type CreateUserClient = typeof client<CreateUserMutationResponse, never, CreateUserMutationRequest>;
type CreateUser = {
data: CreateUserMutationResponse
error: never
request: CreateUserMutationRequest
pathParams: never
queryParams: never
headerParams: never
response: CreateUserMutationResponse
client: {
parameters: Partial<Parameters<CreateUserClient>[0]>
return: Awaited<ReturnType<CreateUserClient>>
}
}
data: CreateUserMutationResponse;
error: never;
request: CreateUserMutationRequest;
pathParams: never;
queryParams: never;
headerParams: never;
response: CreateUserMutationResponse;
client: {
parameters: Partial<Parameters<CreateUserClient>[0]>;
return: Awaited<ReturnType<CreateUserClient>>;
};
};
/**
* @description This can only be done by the logged in user.
* @summary Create user
* @link /user */
* @description This can only be done by the logged in user.
* @summary Create user
* @link /user */
export function useCreateUserHook(options: {
mutation?: UseMutationOptions<CreateUser['response'], CreateUser['error'], CreateUser['request']>
client?: CreateUser['client']['parameters']
mutation?: UseMutationOptions<CreateUser["response"], CreateUser["error"], CreateUser["request"]>;
client?: CreateUser["client"]["parameters"];
} = {}) {
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
return useMutation({
mutationFn: async (data) => {
const res = await client<CreateUser['data'], CreateUser['error'], CreateUser['request']>({
method: 'post',
url: `/user`,
data,
...clientOptions,
})
return res.data
},
...mutationOptions,
})
}
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {};
return useMutation({
mutationFn: async (data) => {
const res = await client<CreateUser["data"], CreateUser["error"], CreateUser["request"]>({
method: "post",
url: `/user`,
data,
...clientOptions
});
return res.data;
},
...mutationOptions
});
}
Loading

0 comments on commit bca653b

Please sign in to comment.