Skip to content

Fix first-party plugin usage when using bundled version of tailwindcss #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tailwindcss-language-server/src/lib/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Hook {
private _origRequire = Module.prototype.require
private _require: (req: string) => any

constructor(find: string, callback: (x) => {}) {
constructor(find: string, callback: (x) => {} = (x) => x) {
// @ts-ignore
if (typeof Module._resolveFilename !== 'function') {
throw new Error(
Expand Down
11 changes: 8 additions & 3 deletions packages/tailwindcss-language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -910,9 +910,14 @@ async function createProjectService(
let hook: Hook

if (loadConfig.module) {
originalConfig = await loadConfig.module(state.configPath)
originalConfig = originalConfig.default ?? originalConfig
state.jit = true
hook = new Hook(fs.realpathSync(state.configPath))
try {
originalConfig = await loadConfig.module(state.configPath)
originalConfig = originalConfig.default ?? originalConfig
state.jit = true
} finally {
hook.unhook()
}
} else {
hook = new Hook(fs.realpathSync(state.configPath), (exports) => {
originalConfig = klona(exports)
Expand Down