File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
packages/tailwindcss-language-server/src Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff 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+
103126interface 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 } ) ) ,
You can’t perform that action at this time.
0 commit comments