Skip to content

Commit

Permalink
Fix remaining linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mrginglymus committed Dec 19, 2024
1 parent 37fa82d commit 2118043
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/node-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs'
import { isBuiltin } from 'node:module'
import { dirname } from 'node:path'
import path from 'node:path'

import { ResolverFactory, CachedInputFileSystem } from 'enhanced-resolve'
import type { ResolveOptions } from 'enhanced-resolve'
Expand All @@ -25,9 +25,9 @@ type NodeResolverOptions = {
export function createNodeResolver({
extensions = ['.mjs', '.cjs', '.js', '.json', '.node'],
conditionNames = ['default', 'module', 'import', 'require'],
mainFields = ['main'],
exportsFields = ['exports'],
mainFiles = ['index'],
mainFields: _mainFields = ['main'],
exportsFields: _exportsFields = ['exports'],
mainFiles: _mainFiles = ['index'],
fileSystem = new CachedInputFileSystem(fs, 4 * 1000),
...restOptions
}: Partial<NodeResolverOptions> = {}): NewResolver {
Expand All @@ -54,9 +54,13 @@ export function createNodeResolver({
}

try {
const path = resolver.resolveSync({}, dirname(sourceFile), modulePath)
if (path) {
return { found: true, path }
const resolved = resolver.resolveSync(
{},
path.dirname(sourceFile),
modulePath,
)
if (resolved) {
return { found: true, path: resolved }
}
return { found: false }
} catch {
Expand Down

0 comments on commit 2118043

Please sign in to comment.