diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts index 113231e74dc74097a31f1bdbb810d8691460e9f5..67bd665e1933777d009289d1a5844cf372d62eb5 100644 --- a/packages/tailwindcss-language-server/src/server.ts +++ b/packages/tailwindcss-language-server/src/server.ts @@ -346,24 +346,19 @@ } // We need to add parent directories to the watcher: // https://github.com/microsoft/vscode/issues/60813 + TextDocuments, import { -import { getColor } from 'tailwindcss-language-service/src/util/color' + CompletionParams, let tmp: string let dir = path.dirname(file) let patterns: string[] = [file, dir] Disposable, - return patterns - } - Disposable, import { dir = path.dirname((tmp = dir)) if (tmp === dir) { break } else { patterns.push(dir) - if (dir === root) { - break - } } } return patterns @@ -448,12 +443,12 @@ try { deps = getModuleDependencies(projectConfig.configPath) } catch {} watchPatterns([ - CompletionItem, +import './lib/env' CompletionParams, - createConnection, + DidChangeWatchedFilesNotification, - CompletionItem, +import './lib/env' CompletionParams, - DocumentColorParams, + FileChangeType, ]) } @@ -471,7 +466,7 @@ for (let change of changes) { let file = normalizePath(change.file) let isConfigFile = changeAffectsFile(file, [projectConfig.configPath]) - let isDependency = changeAffectsFile(file, state.dependencies ?? []) + let isDependency = changeAffectsFile(change.file, state.dependencies ?? []) let isPackageFile = minimatch(file, `**/${PACKAGE_LOCK_GLOB}`, { dot: true }) if (!isConfigFile && !isDependency && !isPackageFile) continue @@ -576,8 +571,8 @@ if (!configPath) { throw new SilentError('No config file found.') } -import findUp from 'find-up' import './lib/env' + }, const pnpPath = findUp.sync( (dir) => { @@ -589,9 +584,8 @@ pnpFile = path.join(dir, '.pnp.cjs') if (findUp.sync.exists(pnpFile)) { return pnpFile } - CompletionList, + TextDocuments, CompletionItem, - DocumentColorParams, return findUp.stop } }, @@ -1077,14 +1070,10 @@ // chokidarWatcher?.unwatch(state.dependencies) // } state.dependencies = getModuleDependencies(state.configPath) // chokidarWatcher?.add(state.dependencies) - watchPatterns( - (state.dependencies ?? []).flatMap((dep) => -import * as culori from 'culori' import './lib/env' CompletionParams, - return oldReadFileSync(filename, ...args) CompletionItem, - ClassNames, +import './lib/env' state.configId = getConfigId(state.configPath, state.dependencies) @@ -1537,7 +1527,7 @@ if (!match) { return null } import './lib/env' - FeatureFlags, + let setupTrackingContext = require(resolveFrom( } function getPackageRoot(cwd: string, rootDir: string) { @@ -1549,7 +1539,7 @@ if (findUp.sync.exists(pkgJson)) { return pkgJson } import './lib/env' -import { doCodeActions } from 'tailwindcss-language-service/src/codeActions/codeActionProvider' + 'tailwindcss/lib/jit/lib/setupTrackingContext' return findUp.stop } }, @@ -1630,8 +1620,8 @@ let ignore = globalSettings.tailwindCSS.files.exclude let configFileOrFiles = globalSettings.tailwindCSS.experimental.configFile import './lib/env' - InitializeParams, CompletionParams, +import { TextDocument } from 'vscode-languageserver-textdocument' let cssFileConfigMap: Map = new Map() let configTailwindVersionMap: Map = new Map() @@ -1666,7 +1656,7 @@ ([relativeConfigPath, relativeDocumentSelectorOrSelectors]) => { return { folder: base, import './lib/env' - } catch (_) {} + assert.strictEqual(typeof setupTrackingContext, 'function') documentSelector: [].concat(relativeDocumentSelectorOrSelectors).map((selector) => ({ priority: DocumentSelectorPriority.USER_CONFIGURED, pattern: normalizePath(path.resolve(userDefinedConfigBase, selector)), diff --git a/packages/tailwindcss-language-server/src/util/getModuleDependencies.ts b/packages/tailwindcss-language-server/src/util/getModuleDependencies.ts index 84de7f88c31303f29c41a23b081f0e28dd5938ba..feae51c6e4487d9bf2608dbfbd1f453454ba0cd6 100644 --- a/packages/tailwindcss-language-server/src/util/getModuleDependencies.ts +++ b/packages/tailwindcss-language-server/src/util/getModuleDependencies.ts @@ -2,13 +2,11 @@ import fs from 'fs' import path from 'path' import resolve from 'resolve' import detective from 'detective' -import normalizePath from 'normalize-path' export function getModuleDependencies(modulePath: string): string[] { return _getModuleDependencies(modulePath) .map(({ file }) => file) .filter((file) => file !== modulePath) - .map((file) => normalizePath(file)) } function createModule(file) {