From ab88ce6e04171bbe13886bad5f6c06080670011c Mon Sep 17 00:00:00 2001 From: mohiit1502 Date: Tue, 23 Dec 2025 00:46:30 +0530 Subject: [PATCH] Fixed module resolution errors --- build.js | 33 +++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index 2c6f659..4efb140 100644 --- a/build.js +++ b/build.js @@ -4,8 +4,37 @@ import fs from "fs-extra"; import childProcess from "child_process"; +import path from "path"; import pkg from "./package.json" with { type: "json" }; +/** + * Add .js extensions to relative imports in compiled JS files + * Required for Node.js ESM module resolution + */ +function addJsExtensions(dir) { + const files = fs.readdirSync(dir); + for (const file of files) { + const filePath = path.join(dir, file); + const stat = fs.statSync(filePath); + if (stat.isDirectory()) { + addJsExtensions(filePath); + } else if (file.endsWith('.js')) { + let content = fs.readFileSync(filePath, 'utf8'); + // Match: from "./something" or from '../something' (without .js extension) + content = content.replace( + /(from\s+['"])(\.\.?\/[^'"]+)(?