feat: add mock-crc module for ESM compatibility

This commit is contained in:
MythEclipse
2026-05-16 21:52:13 +07:00
parent 9ad7d16a17
commit 4825dc6d4d
2 changed files with 6 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import "./mock-crc";
import "libsodium-wrappers"; import "libsodium-wrappers";
import "@snazzah/davey"; import "@snazzah/davey";
import "dotenv/config"; import "dotenv/config";

View File

@@ -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 // Mock node-crc to provide pure JS implementation and bypass native build issues
const CRC_TABLE = new Uint32Array(256); const CRC_TABLE = new Uint32Array(256);
for (let i = 0; i < 256; i++) { for (let i = 0; i < 256; i++) {
@@ -39,4 +42,5 @@ Module.prototype.require = function (id: string) {
return originalRequire.apply(this, arguments); 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 {};