@@ -35,7 +35,7 @@ function getCodeAst(code: string, id: string) {
35
35
let offset = 0
36
36
let ast : Program | undefined
37
37
const lang = getLang ( id . split ( MACRO_DEFINE_PAGE_QUERY ) [ 0 ] ! )
38
-
38
+
39
39
try {
40
40
if ( lang === 'vue' ) {
41
41
const sfc = parseSFC ( code , id )
@@ -109,17 +109,25 @@ export function definePageTransform({
109
109
const routeRecord = definePageNode . arguments [ 0 ]
110
110
111
111
if ( ! routeRecord ) {
112
- warn ( `[${ id } ]: definePage() expects an object expression as its only argument` )
112
+ warn (
113
+ `[${ id } ]: definePage() expects an object expression as its only argument`
114
+ )
113
115
return 'export default {}'
114
116
}
115
117
116
118
const scriptBindings = ast . body ? getIdentifiers ( ast . body ) : [ ]
117
119
118
120
// this will throw if a property from the script setup is used in definePage
119
121
try {
120
- checkInvalidScopeReference ( routeRecord , MACRO_DEFINE_PAGE , scriptBindings )
122
+ checkInvalidScopeReference (
123
+ routeRecord ,
124
+ MACRO_DEFINE_PAGE ,
125
+ scriptBindings
126
+ )
121
127
} catch ( error ) {
122
- warn ( `[${ id } ]: ${ error instanceof Error ? error . message : 'Invalid scope reference in definePage' } ` )
128
+ warn (
129
+ `[${ id } ]: ${ error instanceof Error ? error . message : 'Invalid scope reference in definePage' } `
130
+ )
123
131
return 'export default {}'
124
132
}
125
133
@@ -199,7 +207,9 @@ export function definePageTransform({
199
207
}
200
208
} catch ( error ) {
201
209
// Handle any syntax errors or parsing errors gracefully
202
- warn ( `[${ id } ]: Failed to process definePage: ${ error instanceof Error ? error . message : 'Unknown error' } ` )
210
+ warn (
211
+ `[${ id } ]: Failed to process definePage: ${ error instanceof Error ? error . message : 'Unknown error' } `
212
+ )
203
213
return isExtractingDefinePage ? 'export default {}' : undefined
204
214
}
205
215
}
@@ -225,12 +235,16 @@ export function extractDefinePageNameAndPath(
225
235
226
236
const routeRecord = definePageNode . arguments [ 0 ]
227
237
if ( ! routeRecord ) {
228
- warn ( `[${ id } ]: definePage() expects an object expression as its only argument` )
238
+ warn (
239
+ `[${ id } ]: definePage() expects an object expression as its only argument`
240
+ )
229
241
return
230
242
}
231
243
232
244
if ( routeRecord . type !== 'ObjectExpression' ) {
233
- warn ( `[${ id } ]: definePage() expects an object expression as its only argument` )
245
+ warn (
246
+ `[${ id } ]: definePage() expects an object expression as its only argument`
247
+ )
234
248
return
235
249
}
236
250
@@ -263,7 +277,9 @@ export function extractDefinePageNameAndPath(
263
277
return routeInfo
264
278
} catch ( error ) {
265
279
// Handle any syntax errors or parsing errors gracefully
266
- warn ( `[${ id } ]: Failed to extract definePage info: ${ error instanceof Error ? error . message : 'Unknown error' } ` )
280
+ warn (
281
+ `[${ id } ]: Failed to extract definePage info: ${ error instanceof Error ? error . message : 'Unknown error' } `
282
+ )
267
283
return
268
284
}
269
285
}
0 commit comments