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

Commit

Permalink
fix: update resolver to support protocol imports
Browse files Browse the repository at this point in the history
NOTE: Augment the original builtin behaviour to use `module.isBuiltin` when available, to support protocol imports (e.g. "node:fs/promises"). The original implementation remains as a fallback
  • Loading branch information
cjntaylor committed Nov 13, 2023
1 parent d5e34a4 commit ed9fb6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion eslint-import-resolver-require/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tophat/eslint-import-resolver-require",
"version": "1.0.0",
"version": "1.0.1",
"repository": {
"type": "git",
"url": "https://github.com/tophat/eslint-config.git",
Expand Down
9 changes: 5 additions & 4 deletions eslint-import-resolver-require/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { builtinModules } from 'module'
import module from 'module'
import path from 'path'

const builtins = new Set(builtinModules)
const builtinModules = new Set(module.builtinModules)
const isBuiltin = module.isBuiltin || builtinModules.has

const resolve = (source: string, file: string) => {
if (builtins.has(source)) {
return { found: true }
if (isBuiltin(source)) {
return { found: true, path: null }
}

try {
Expand Down

0 comments on commit ed9fb6f

Please sign in to comment.