Skip to content

Commit 4b0f271

Browse files
committed
feat: handle typescript-language-features module loading race condition
See vuejs/language-tools#5260.
1 parent 7d664b8 commit 4b0f271

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/extension.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ try {
166166

167167
return readFileSyncUnpatched(...args)
168168
}
169+
170+
const loadedModule = require.cache[extensionJsPath]
171+
if (loadedModule) {
172+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
173+
delete require.cache[extensionJsPath]
174+
const patchedModule = require(extensionJsPath)
175+
Object.assign(loadedModule.exports, patchedModule)
176+
}
177+
178+
if (tsExtension.isActive) {
179+
void vscode.commands.executeCommand('workbench.action.restartExtensionHost')
180+
}
169181
} catch (e) {
170182
console.error('Error patching TS extension', e)
171183
}

0 commit comments

Comments
 (0)