Skip to content

🎥 Make videos programmatically with React

Resolve Twoslash libraries from its TypeScript 5 dependency

Jonny Burger61d205d796ba
diff --git a/packages/typescript-tools/twoslash.mjs b/packages/typescript-tools/twoslash.mjs
index 6843294e68..8d7c106893 100644
--- a/packages/typescript-tools/twoslash.mjs
+++ b/packages/typescript-tools/twoslash.mjs
@@ -1 +1,17 @@
+import {createRequire} from 'node:module';
+import {dirname} from 'node:path';
+import {createTwoslasher as createOriginalTwoslasher} from 'twoslash';
+
export * from 'twoslash';
+
+const require = createRequire(import.meta.url);
+const toolingRequire = createRequire(
+ require.resolve('@remotion/typescript-tools/package.json'),
+);
+
+export const createTwoslasher = (options = {}) =>
+ createOriginalTwoslasher({
+ // Bundled workers otherwise resolve the root TypeScript 7 library directory.
+ tsLibDirectory: dirname(toolingRequire.resolve('typescript')),
+ ...options,
+ });