Skip to content

Commit 77586d1

Browse files
committed
wip
1 parent 21c7dca commit 77586d1

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as rpc from 'vscode-jsonrpc/node'
22
import * as proc from 'node:child_process'
33
import * as path from 'node:path'
4+
import * as fs from 'node:fs/promises'
45
import { type ScanOptions, type ScanResult } from './oxide'
56

67
/**
@@ -32,7 +33,32 @@ export class OxideSession {
3233

3334
// TODO: Can we find a way to not require a build first?
3435
// let module = path.resolve(path.dirname(__filename), './oxide-helper.ts')
35-
let module = path.resolve(path.dirname(__filename), '../bin/oxide-helper.js')
36+
37+
let modulePaths = [
38+
// Separate Language Server package
39+
'../bin/oxide-helper.js',
40+
41+
// Bundled with the VSCode extension
42+
'../dist/oxide-helper.js',
43+
]
44+
45+
let module: string | null = null
46+
47+
for (let relativePath of modulePaths) {
48+
let filepath = path.resolve(path.dirname(__filename), relativePath)
49+
50+
if (
51+
await fs.access(filepath).then(
52+
() => true,
53+
() => false,
54+
)
55+
) {
56+
module = filepath
57+
break
58+
}
59+
}
60+
61+
if (!module) throw new Error('unable to load')
3662

3763
let helper = proc.fork(module)
3864
let connection = rpc.createMessageConnection(

packages/vscode-tailwindcss/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
}
363363
},
364364
"scripts": {
365-
"_esbuild": "node ../../esbuild.mjs src/extension.ts src/server.ts src/cssServer.ts --outdir=dist",
365+
"_esbuild": "node ../../esbuild.mjs src/extension.ts src/server.ts src/cssServer.ts src/oxide-helper.ts --outdir=dist",
366366
"dev": "concurrently --raw --kill-others \"pnpm run watch\" \"pnpm run check --watch\"",
367367
"watch": "pnpm run clean && pnpm run _esbuild --watch",
368368
"build": "pnpm run check && pnpm run clean && pnpm run _esbuild --minify && move-file dist/server.js dist/tailwindServer.js && move-file dist/cssServer.js dist/tailwindModeServer.js",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@tailwindcss/language-server/src/oxide-helper'

0 commit comments

Comments
 (0)