Skip to content

Commit

Permalink
fix(loader): use default export if is the only export
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 5, 2024
1 parent e067210 commit 030a98c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ export async function loadSchema(
} satisfies JitiOptions),
);

const rawSchema = (await jiti.import(entryPath)) as InputObject;
let rawSchema = (await jiti.import(entryPath)) as InputObject;

const rawSchemaKeys = Object.keys(rawSchema);
if (rawSchemaKeys.length === 1 && rawSchemaKeys[0] === "default") {
rawSchema = (rawSchema as any).default;
}

const schema = await resolveSchema(rawSchema, options.defaults, {
ignoreDefaults: options.ignoreDefaults,
});
Expand Down

0 comments on commit 030a98c

Please sign in to comment.