Skip to content

Commit

Permalink
fix: imports aren't always plain objects
Browse files Browse the repository at this point in the history
  • Loading branch information
apaleslimghost committed Jan 9, 2025
1 parent 90ec26a commit 5ae739e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions core/cli/src/plugin/entry-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function importEntryPoint<T extends { name: string } & Omit<typeof
])
}

let pluginModule: unknown
let pluginModule: any
try {
pluginModule = require(resolvedPath)
} catch (e) {
Expand All @@ -37,18 +37,16 @@ export async function importEntryPoint<T extends { name: string } & Omit<typeof
])
}

if (isPlainObjectGuard(pluginModule)) {
const defaultExport = __importDefault(pluginModule).default

if (typeof defaultExport === 'function') {
return type
.isCompatible<T>(defaultExport)
.mapError((reasons) => [
`the ${type.name.toLowerCase()} ${s.hook(
defaultExport.name
)} is not a compatible instance of ${s.code(type.name)}:\n - ${reasons.join('\n - ')}`
])
}
const defaultExport = __importDefault(pluginModule).default

if (typeof defaultExport === 'function') {
return type
.isCompatible<T>(defaultExport)
.mapError((reasons) => [
`the ${type.name.toLowerCase()} ${s.hook(
defaultExport.name
)} is not a compatible instance of ${s.code(type.name)}:\n - ${reasons.join('\n - ')}`
])
}

return invalid([
Expand Down

0 comments on commit 5ae739e

Please sign in to comment.