Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/extensions/first-party-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,39 @@ describe("first-party extension imports", () => {
);
});

it("parses the Deno npm-referrer missing-package shape", () => {
// Deno reports an unresolvable npm package differently when the importer
// itself lives inside the npm cache, which is exactly what a scaffolded
// `deno task dev` hits while probing optional first-party extensions.
const denoNpmReferrer = Object.assign(
new Error(
`Could not find package '@veryfront/ext-auth-jwt' from referrer 'file:///app/node_modules/.deno/veryfront@0.1.0/node_modules/veryfront/esm/src/extensions/first-party-import.js'.`,
),
{ code: "ERR_MODULE_NOT_FOUND" },
);
assertEquals(
isMissingFirstPartyExtensionModule(denoNpmReferrer, [
"@veryfront/ext-auth-jwt",
]),
true,
);

// A broken transitive dependency of an installed extension must still be
// surfaced rather than swallowed as "extension not installed".
const transitiveFailure = Object.assign(
new Error(
`Could not find package 'jose' from referrer 'file:///app/node_modules/@veryfront/ext-auth-jwt/esm/src/index.js'.`,
),
{ code: "ERR_MODULE_NOT_FOUND" },
);
assertEquals(
isMissingFirstPartyExtensionModule(transitiveFailure, [
"@veryfront/ext-auth-jwt",
]),
false,
);
});

it("parses Bun relative, package, and object-shaped missing-module errors", () => {
const relativeError = Object.assign(
new Error(
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/first-party-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ function reportedMissingSpecifier(message: string): string | undefined {
const pattern of [
/^Cannot find module\s+["']([^"']+)["']\nRequire stack:(?:\n- [^\r\n]+)+$/,
/^(?:Cannot find package|Cannot find module|Module not found)\s+["']([^"']+)["'](?:(?:\s+imported from\s+.+)|\.)?$/,
// Deno, when the importer itself resolves out of the npm cache.
/^Could not find package\s+["']([^"']+)["']\s+from referrer\s+["'][^"']+["']\.?$/,
/^Import\s+["']([^"']+)["']\s+not a dependency(?: and not in import map)?(?:\s+from\s+.+)?$/,
/^Unable to resolve\s+["']([^"']+)["'](?:\s+from\s+.+)?$/,
]
Expand Down