Skip to content

Commit

Permalink
feat: export built-in resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
hannoeru committed Jun 28, 2022
1 parent 7723084 commit 97e01b1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export type {
SolidRoute,
} from './resolvers'

export {
vueResolver,
reactResolver,
solidResolver,
} from './resolvers'
export { syncIndexResolver } from './options'
export { PageContext }
export default pagesPlugin
8 changes: 4 additions & 4 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { resolve } from 'path'
import { slash, toArray } from '@antfu/utils'
import { getPageDirs } from './files'

import { ReactResolver, SolidResolver, VueResolver } from './resolvers'
import { reactResolver, solidResolver, vueResolver } from './resolvers'
import { MODULE_IDS } from './constants'
import type { ImportModeResolver, ResolvedOptions, UserOptions } from './types'

Expand Down Expand Up @@ -36,13 +36,13 @@ const getResolver = (originalResolver: UserOptions['resolver']) => {

switch (resolver) {
case 'vue':
resolver = VueResolver()
resolver = vueResolver()
break
case 'react':
resolver = ReactResolver()
resolver = reactResolver()
break
case 'solid':
resolver = SolidResolver()
resolver = solidResolver()
break
default:
throw new Error(`Unsupported resolver: ${resolver}`)
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async function resolveReactRoutes(ctx: PageContext) {
return client
}

export function ReactResolver(): PageResolver {
export function reactResolver(): PageResolver {
return {
resolveModuleIds() {
return ['~react-pages', 'virtual:generated-pages-react']
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/solid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function resolveSolidRoutes(ctx: PageContext) {
return client
}

export function SolidResolver(): PageResolver {
export function solidResolver(): PageResolver {
return {
resolveModuleIds() {
return ['~solid-pages']
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async function resolveVueRoutes(ctx: PageContext, customBlockMap: Map<string, Cu
return client
}

export function VueResolver(): PageResolver {
export function vueResolver(): PageResolver {
const customBlockMap = new Map<string, CustomBlock>()

async function checkCustomBlockChange(ctx: PageContext, path: string) {
Expand Down

0 comments on commit 97e01b1

Please sign in to comment.