fix(matrix): load crypto-nodejs via createRequire to fix __dirname in ESM

This commit is contained in:
joelnishanth
2026-03-25 09:42:29 -07:00
committed by Gustavo Madeira Santana
parent 2022dfd0a1
commit 6f98ee7f62

View File

@@ -1,3 +1,9 @@
import { Attachment, EncryptedAttachment } from "@matrix-org/matrix-sdk-crypto-nodejs";
import { createRequire } from "node:module";
// Load via createRequire so the CJS package gets __dirname (its index.js
// uses __dirname to locate platform-specific native .node bindings).
const require = createRequire(import.meta.url);
const { Attachment, EncryptedAttachment } =
require("@matrix-org/matrix-sdk-crypto-nodejs") as typeof import("@matrix-org/matrix-sdk-crypto-nodejs");
export { Attachment, EncryptedAttachment };