Skip to content

Commit

Permalink
Fix server not launching on older versions of VSCode (#998)
Browse files Browse the repository at this point in the history
* Fix loading on old versions of VSCode

* Update changelog
  • Loading branch information
thecrypticace authored Jun 27, 2024
1 parent 405502b commit 413f4f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/tailwindcss-language-server/src/lib/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Module from 'node:module'
import { isBuiltin } from 'node:module'
import * as path from 'node:path'
import resolveFrom from '../util/resolveFrom'

Expand All @@ -8,6 +7,18 @@ process.env.TAILWIND_DISABLE_TOUCH = 'true'

let oldResolveFilename = (Module as any)._resolveFilename

function isBuiltin(id: string) {
// Node 16.17+, v18.6.0+, >= v20
// VSCode >= 1.78
if ('isBuiltin' in Module) {
return Module.isBuiltin(id)
}

// Older versions of Node and VSCode
// @ts-ignore
return Module.builtinModules.includes(id.replace(/^node:/, ''))
}

;(Module as any)._resolveFilename = (id: any, parent: any) => {
if (typeof id === 'string' && isBuiltin(id)) {
return oldResolveFilename(id, parent)
Expand Down
1 change: 1 addition & 0 deletions packages/vscode-tailwindcss/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Prerelease

- Fix loading projects on Windows network drives ([#996](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/996))
- Fix server not launching on older versions of VSCode ([#998](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/998))

## 0.12.1

Expand Down

0 comments on commit 413f4f1

Please sign in to comment.