Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Dec 26, 2023
1 parent 14701aa commit 588dd67
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/vinxi-doc/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { createRequire } from "node:module";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";

/**
*
* @param {string} src
* @returns {Promise<import('./types.d.ts').DocNode[]>}
*/
export async function doc(src) {
const require = createRequire(import.meta.url);
const mod = require("@vinxi/deno-doc");
Expand Down Expand Up @@ -66,6 +71,12 @@ export async function doc(src) {

function resolvePackage(specifier, referrer) {
try {
// console.log("resolvePackage", specifier, referrer);

if (specifier.startsWith("node:")) {
return new URL("./empty.d.ts", import.meta.url).toString();
}

const resolved = resolve.sync(specifier, {
preserveSymlinks: false,
basedir: path.dirname(new URL(referrer).pathname),
Expand All @@ -80,7 +91,7 @@ export async function doc(src) {
return "file://" + resolved;
} catch (e) {
console.error(e);
return null;
return new URL("./empty.d.ts", import.meta.url).toString();
}
}

Expand Down

0 comments on commit 588dd67

Please sign in to comment.