11import { defu } from "defu" ;
2- import jiti from "jiti" ;
3- import type { JITIOptions } from "jiti" ;
2+ import { createJiti , type JitiOptions } from "jiti" ;
43import { resolveSchema } from "../schema" ;
5- import type { Schema } from "../types" ;
4+ import type { InputObject , Schema } from "../types" ;
65import untypedPlugin from "./babel" ;
76
87export interface LoaderOptions {
9- jiti ?: JITIOptions ;
8+ jiti ?: JitiOptions ;
109 defaults ?: Record < string , any > ;
1110 ignoreDefaults ?: boolean ;
1211}
@@ -15,21 +14,19 @@ export async function loadSchema(
1514 entryPath : string ,
1615 options : LoaderOptions = { } ,
1716) : Promise < Schema > {
18- const _jitiRequire = jiti (
17+ const jiti = createJiti (
1918 process . cwd ( ) ,
2019 defu ( options . jiti , {
21- esmResolve : true ,
2220 interopDefault : true ,
2321 transformOptions : {
2422 babel : {
2523 plugins : [ [ untypedPlugin , { experimentalFunctions : true } ] ] ,
2624 } ,
2725 } ,
28- } ) ,
26+ } satisfies JitiOptions ) ,
2927 ) ;
3028
31- const resolvedEntryPath = _jitiRequire . resolve ( entryPath ) ;
32- const rawSchema = _jitiRequire ( resolvedEntryPath ) ;
29+ const rawSchema = await jiti . import ( entryPath ) as InputObject ;
3330 const schema = await resolveSchema ( rawSchema , options . defaults , {
3431 ignoreDefaults : options . ignoreDefaults ,
3532 } ) ;
0 commit comments