Skip to content

Commit

Permalink
refactor: use invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Nov 6, 2021
1 parent 28635c8 commit 3bfcb07
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/jest-runtime/src/index.ts
Expand Up @@ -648,14 +648,16 @@ export default class Runtime {
const isSourceTextModule = (module: unknown): module is SourceTextModule =>
module instanceof SourceTextModule;

if (
invariant(
isSourceTextModule(evaluatedModule) &&
evaluatedModule.namespace.default !== undefined
) {
return {default: evaluatedModule.namespace.default};
}
evaluatedModule.namespace.default !== undefined,
`"${path.relative(
'',
evaluatedModule.identifier,
)}" must be a node module with default export.`,
);

throw new Error(`Module ${from} must have default export.`);
return {default: evaluatedModule.namespace.default};
}

private loadCjsAsEsm(
Expand Down

0 comments on commit 3bfcb07

Please sign in to comment.