Skip to content

Commit

Permalink
fix: use builtinModules from module (#358)
Browse files Browse the repository at this point in the history
This feels like the better choice rather than using a private property
on `repl`.

supported as of
[v6.13.0](https://nodejs.org/api/module.html#modulebuiltinmodules)
  • Loading branch information
danielroe authored Aug 14, 2023
1 parent 13f93c5 commit bcb71fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/resolve-dependency.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isAbsolute, resolve, sep } from 'path';
import { builtinModules } from 'module';
import { Job } from './node-file-trace';

// node resolver
Expand Down Expand Up @@ -68,7 +69,7 @@ export class NotFoundError extends Error {
}
}

const nodeBuiltins = new Set<string>([...require("repl")._builtinLibs, "constants", "module", "timers", "console", "_stream_writable", "_stream_readable", "_stream_duplex", "process", "sys"]);
const nodeBuiltins = new Set<string>(builtinModules);

function getPkgName (name: string) {
const segments = name.split('/');
Expand Down Expand Up @@ -267,4 +268,4 @@ async function resolvePackage (name: string, parent: string, job: Job, cjsResolv
}
}
throw new NotFoundError(name, parent);
}
}

0 comments on commit bcb71fd

Please sign in to comment.