Skip to content

Commit

Permalink
feat: use awaitable on custom hooks
Browse files Browse the repository at this point in the history
close #179
  • Loading branch information
hannoeru committed Mar 2, 2022
1 parent 41f8454 commit 6a50c94
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const config = defineConfig({
{ dir: 'src/admin/pages', baseRoute: 'admin' },
],
extensions: ['vue', 'md'],
extendRoute(route) {
extendRoute(route: any) {
if (route.name === 'about')
route.props = (route: any) => ({ query: route.query.q })

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"bugs": "https://github.com/hannoeru/vite-plugin-pages/issues",
"scripts": {
"dev": "npm run build -- --watch --ignore-watch examples",
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
"build": "tsup",
"prepublishOnly": "npm run build",
"release": "bumpp --commit --tag --push",
"publish:ci": "esno scripts/publish.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Awaitable } from '@antfu/utils'

export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>

export type ImportMode = 'sync' | 'async'
Expand Down Expand Up @@ -67,11 +69,11 @@ interface Options {
/**
* Custom generated routes
*/
onRoutesGenerated?: (routes: any[]) => any[] | Promise<any[] | void>
onRoutesGenerated?: (routes: any[]) => Awaitable<any[] | void>
/**
* Custom generated client code
*/
onClientGenerated?: (clientCode: string) => string | Promise<string | void>
onClientGenerated?: (clientCode: string) => Awaitable<string | void>

/**
* Paths to the directory to search for page components.
Expand Down
11 changes: 11 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: {
resolve: true,
},
clean: true,
sourcemap: true,
})

0 comments on commit 6a50c94

Please sign in to comment.