Skip to content

Commit

Permalink
feat(compartment-mapper): improve unresolved module error message
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Oct 19, 2023
1 parent 65c7750 commit 323ca32
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ export const wrap = ({
});

const require = (/** @type {string} */ importSpecifier) => {
if (!has(resolvedImports, importSpecifier)) {
throw new Error(
`Cannot find module "${importSpecifier}" in "${location}"`,
);
}
const namespace = compartment.importNow(resolvedImports[importSpecifier]);
// If you read this file carefully, you'll see it's not possible for a cjs module to not have the default anymore.
// It's currently possible to require modules that were not created by this file though.
Expand Down

0 comments on commit 323ca32

Please sign in to comment.