Skip to content

Commit b8416c7

Browse files
committed
speculative fix
1 parent 59b34d2 commit b8416c7

File tree

1 file changed

+26
-0
lines changed
  • packages/tailwindcss-language-server/src

1 file changed

+26
-0
lines changed

packages/tailwindcss-language-server/src/oxide.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,29 @@ async function loadOxideAtPath(id: string): Promise<Oxide | null> {
100100
return oxide
101101
}
102102

103+
/**
104+
* This function exists because doing a require(…) on the .node file for Oxide
105+
* loads it into the processes address space. This marks the file as in use
106+
* preventing it from being deleted during something like `npm ci`.
107+
*
108+
* This is unnecessary if you're on a *nix-based OS like linux or macOS
109+
* so we don't do this work. Additionally, unloading Oxide for earlier
110+
* releases could crash (though this might be *nix only):
111+
*
112+
* https://github.com/rust-lang/rust/issues/91979
113+
* https://github.com/tailwindlabs/tailwindcss/pull/17276
114+
*/
115+
function unloadOxideIfWindows(): void {
116+
if (process.platform !== 'win32') return
117+
118+
for (let key of Object.keys(require.cache)) {
119+
if (!key.endsWith('-msvc.node')) continue
120+
if (!key.includes('oxide-win32')) continue
121+
122+
delete require.cache[key]
123+
}
124+
}
125+
103126
interface GlobEntry {
104127
base: string
105128
pattern: string
@@ -200,6 +223,9 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
200223
],
201224
})
202225

226+
// We only do this for v4.1.x and later
227+
unloadOxideIfWindows()
228+
203229
return {
204230
files: scanner.files,
205231
globs: scanner.globs.map((g) => ({ base: g.base, pattern: g.pattern })),

0 commit comments

Comments
 (0)