Skip to content

Commit

Permalink
feat: remove is-builtin-module dependency (#970)
Browse files Browse the repository at this point in the history
* feat: remove is-builtin-module dependency

Node provides a list of built ins via `builtinModules`. We can test
against this rather than including an extra (redundant) dependency.

In future, if we introduce a version constraint of node `>=16`, we can
use `isBuiltin` which node provides:

```ts
import {isBuiltin} from 'node:module';

isBuiltin('fs'); // true
```

* Simplify code

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
  • Loading branch information
43081j and thecrypticace committed Jun 4, 2024
1 parent 28cefbf commit ff094cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
28 changes: 0 additions & 28 deletions package-lock.json

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

1 change: 0 additions & 1 deletion packages/tailwindcss-language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"enhanced-resolve": "^5.16.1",
"fast-glob": "3.2.4",
"find-up": "5.0.0",
"is-builtin-module": "3.2.1",
"klona": "2.0.4",
"license-checker": "25.0.1",
"minimist": "^1.2.8",
Expand Down
8 changes: 4 additions & 4 deletions packages/tailwindcss-language-server/src/lib/env.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Module from 'module'
import * as path from 'path'
import Module from 'node:module'
import { isBuiltin } from 'node:module'
import * as path from 'node:path'
import resolveFrom from '../util/resolveFrom'
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' && isBuiltinModule(id)) {
if (typeof id === 'string' && isBuiltin(id)) {
return oldResolveFilename(id, parent)
}

Expand Down

0 comments on commit ff094cf

Please sign in to comment.