File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,11 @@ export function createRoutesContext(options: ResolvedOptions) {
105
105
const content = await fs . readFile ( filePath , 'utf8' )
106
106
// TODO: cache the result of parsing the SFC so the transform can reuse the parsing
107
107
node . hasDefinePage ||= content . includes ( 'definePage' )
108
- const [ definedPageNameAndPath , routeBlock ] = await Promise . all ( [
109
- extractDefinePageNameAndPath ( content , filePath ) ,
110
- getRouteBlock ( filePath , options ) ,
111
- ] )
108
+ const definedPageNameAndPath = extractDefinePageNameAndPath (
109
+ content ,
110
+ filePath
111
+ )
112
+ const routeBlock = getRouteBlock ( filePath , content , options )
112
113
// TODO: should warn if hasDefinePage and customRouteBlock
113
114
// if (routeBlock) logger.log(routeBlock)
114
115
node . setCustomRouteBlock ( filePath , {
Original file line number Diff line number Diff line change 1
1
import { SFCBlock , parse } from '@vue/compiler-sfc'
2
- import fs from 'node:fs/promises'
3
2
import { ResolvedOptions } from '../options'
4
3
import JSON5 from 'json5'
5
4
import { parse as YAMLParser } from 'yaml'
6
5
import { RouteRecordRaw } from 'vue-router'
7
6
import { warn } from './utils'
8
7
9
- export async function getRouteBlock ( path : string , options : ResolvedOptions ) {
10
- const content = await fs . readFile ( path , 'utf8' )
11
-
12
- const parsedSFC = await parse ( content , { pad : 'space' } ) . descriptor
8
+ export function getRouteBlock (
9
+ path : string ,
10
+ content : string ,
11
+ options : ResolvedOptions
12
+ ) {
13
+ const parsedSFC = parse ( content , { pad : 'space' } ) . descriptor
13
14
const blockStr = parsedSFC ?. customBlocks . find ( ( b ) => b . type === 'route' )
14
15
15
16
if ( ! blockStr ) return
You can’t perform that action at this time.
0 commit comments