From 4825dc6d4d0a86674a5e86683d540adb6913ef2c Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Sat, 16 May 2026 21:52:13 +0700 Subject: [PATCH] feat: add mock-crc module for ESM compatibility --- src/index.ts | 1 + src/mock-crc.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index b2b4b5e..a839bb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +import "./mock-crc"; import "libsodium-wrappers"; import "@snazzah/davey"; import "dotenv/config"; diff --git a/src/mock-crc.ts b/src/mock-crc.ts index e73b8ed..037c9bf 100644 --- a/src/mock-crc.ts +++ b/src/mock-crc.ts @@ -1,3 +1,6 @@ +import { createRequire } from "node:module"; +const require = createRequire(import.meta.url); + // Mock node-crc to provide pure JS implementation and bypass native build issues const CRC_TABLE = new Uint32Array(256); for (let i = 0; i < 256; i++) { @@ -39,4 +42,5 @@ Module.prototype.require = function (id: string) { return originalRequire.apply(this, arguments); }; -console.log("[mock] node-crc has been mocked globally."); +console.log("[mock] node-crc has been mocked globally for ESM."); +export {};