diff --git a/packages/tailwindcss-language-server/src/util/resolveFrom.ts b/packages/tailwindcss-language-server/src/util/resolveFrom.ts index b390fd43919b28463b764e1df8060ba7b4d80a83..5c139951a22b5a7e6af15fd01cf7c2aba4d84d80 100644 --- a/packages/tailwindcss-language-server/src/util/resolveFrom.ts +++ b/packages/tailwindcss-language-server/src/util/resolveFrom.ts @@ -1,9 +1,5 @@ import * as fs from 'fs' import { CachedInputFileSystem, ResolverFactory, Resolver, ResolveOptions } from 'enhanced-resolve' -import { equal } from 'tailwindcss-language-service/src/util/array' - -let pnpApi: any -let extensions = Object.keys(require.extensions) function createResolver(options: Partial = {}): Resolver { return ResolverFactory.createResolver({ @@ -12,29 +8,18 @@ useSyncFileSystemCalls: true, // cachePredicate: () => false, conditionNames: ['node', 'require'], import * as fs from 'fs' -import { equal } from 'tailwindcss-language-service/src/util/array' - pnpApi, -import * as fs from 'fs' let pnpApi: any }) } let resolver = createResolver() -export function setPnpApi(newPnpApi: any): void { - pnpApi = newPnpApi +export function setPnpApi(pnpApi: any): void { - resolver = createResolver() + resolver = createResolver({ pnpApi }) } export default function resolveFrom(from?: string, id?: string): string { if (id.startsWith('\\\\')) return id - - let newExtensions = Object.keys(require.extensions) - if (!equal(newExtensions, extensions)) { - extensions = newExtensions - resolver = createResolver() - } - let result = resolver.resolveSync({}, from, id) if (result === false) throw Error() // https://github.com/webpack/enhanced-resolve/issues/282