Skip to content

Commit

Permalink
fix: enhanced-resolve is commonjs only
Browse files Browse the repository at this point in the history
close #213
  • Loading branch information
JounQin committed Mar 29, 2023
1 parent 0bf6ffb commit 8ac6e4c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ import path from 'node:path'
import { fileURLToPath } from 'node:url'

import debug from 'debug'
import {
FileSystem,
CachedInputFileSystem,
ResolveOptions,
Resolver,
ResolverFactory,
} from 'enhanced-resolve'
import type { FileSystem, ResolveOptions, Resolver } from 'enhanced-resolve'
import enhancedResolve from 'enhanced-resolve'
import { hashObject } from 'eslint-module-utils/hash.js'
import { createPathsMatcher, getTsconfig } from 'get-tsconfig'
import type { TsConfigResult } from 'get-tsconfig'
Expand Down Expand Up @@ -155,13 +150,16 @@ export function resolve(
extensions: options?.extensions ?? defaultExtensions,
extensionAlias: options?.extensionAlias ?? defaultExtensionAlias,
mainFields: options?.mainFields ?? defaultMainFields,
fileSystem: new CachedInputFileSystem(fileSystem, 5 * 1000),
fileSystem: new enhancedResolve.CachedInputFileSystem(
fileSystem,
5 * 1000,
),
useSyncFileSystemCalls: true,
}
}

if (!resolver || resolverCachedOptions !== cachedOptions) {
resolver = ResolverFactory.createResolver(cachedOptions)
resolver = enhancedResolve.ResolverFactory.createResolver(cachedOptions)
resolverCachedOptions = cachedOptions
}

Expand Down

0 comments on commit 8ac6e4c

Please sign in to comment.