Skip to content

Commit 2e2dcc2

Browse files
authored
Fix first-party plugin usage when using bundled version of tailwindcss (#751)
1 parent c0d593a commit 2e2dcc2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/tailwindcss-language-server/src/lib/hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class Hook {
2020
private _origRequire = Module.prototype.require
2121
private _require: (req: string) => any
2222

23-
constructor(find: string, callback: (x) => {}) {
23+
constructor(find: string, callback: (x) => {} = (x) => x) {
2424
// @ts-ignore
2525
if (typeof Module._resolveFilename !== 'function') {
2626
throw new Error(

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,14 @@ async function createProjectService(
910910
let hook: Hook
911911

912912
if (loadConfig.module) {
913-
originalConfig = await loadConfig.module(state.configPath)
914-
originalConfig = originalConfig.default ?? originalConfig
915-
state.jit = true
913+
hook = new Hook(fs.realpathSync(state.configPath))
914+
try {
915+
originalConfig = await loadConfig.module(state.configPath)
916+
originalConfig = originalConfig.default ?? originalConfig
917+
state.jit = true
918+
} finally {
919+
hook.unhook()
920+
}
916921
} else {
917922
hook = new Hook(fs.realpathSync(state.configPath), (exports) => {
918923
originalConfig = klona(exports)

0 commit comments

Comments
 (0)