Skip to content

Commit

Permalink
Fix use of certain built-in node modules in config file (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlc authored Mar 26, 2023
1 parent 89dd104 commit 33f94ba
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
36 changes: 29 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/tailwindcss-language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@types/debounce": "1.2.0",
"@types/node": "14.14.34",
"@types/vscode": "1.65.0",
"builtin-modules": "3.2.0",
"chokidar": "3.5.1",
"color-name": "1.1.4",
"culori": "0.20.1",
Expand All @@ -51,6 +50,7 @@
"enhanced-resolve-301": "0.0.1",
"fast-glob": "3.2.4",
"find-up": "5.0.0",
"is-builtin-module": "3.2.1",
"jest": "25.5.4",
"klona": "2.0.4",
"license-checker": "25.0.1",
Expand Down
7 changes: 2 additions & 5 deletions packages/tailwindcss-language-server/src/lib/env.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import Module from 'module'
import * as path from 'path'
import resolveFrom from '../util/resolveFrom'
import builtInModules from 'builtin-modules'
import isBuiltinModule from 'is-builtin-module'

process.env.TAILWIND_MODE = 'build'
process.env.TAILWIND_DISABLE_TOUCH = 'true'

let oldResolveFilename = (Module as any)._resolveFilename

;(Module as any)._resolveFilename = (id: any, parent: any) => {
if (
typeof id === 'string' &&
(builtInModules.includes(id) || builtInModules.includes(id.replace(/^node:/, '')))
) {
if (typeof id === 'string' && isBuiltinModule(id)) {
return oldResolveFilename(id, parent)
}
return resolveFrom(path.dirname(parent.id), id)
Expand Down

0 comments on commit 33f94ba

Please sign in to comment.