Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Detect node: as builtin
Browse files Browse the repository at this point in the history
Fixes Resolve `node:` dependencies as built-in #193
  • Loading branch information
voxpelli committed Nov 22, 2021
1 parent 558f047 commit 1f0eafa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/resolve-dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const getDeps = async function (file, extensions, { deps, seen, core }) {
const relatives = []

for (let req of requires) {
const isCore = builtins.includes(req)
const isCore = builtins.includes(req.startsWith('node:') ? req.slice(5) : req)

if (isNotRelative(req) && !isCore) {
// require('foo/bar') -> require('foo')
if (req[0] !== '@' && req.includes('/')) req = req.split('/')[0] || ''
Expand Down
2 changes: 2 additions & 0 deletions test/mock-negative/index.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
import http from 'http'
import path from 'node:path'
import example from 'example'
import foo from './foo.js'

0 comments on commit 1f0eafa

Please sign in to comment.