Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix: .mjs imports not being updated by bable

Daniel Hougaard4c2f7fff5c6f
diff --git a/backend/scripts/rename-mjs.ts b/backend/scripts/rename-mjs.ts
new file mode 100644
index 0000000000..793cb98917
--- /dev/null
+++ b/backend/scripts/rename-mjs.ts
@@ -0,0 +1,27 @@
+/* eslint-disable @typescript-eslint/no-shadow */
+import fs from "node:fs";
+import path from "node:path";
+
+function replaceMjsOccurrences(directory: string) {
+ fs.readdir(directory, (err, files) => {
+ if (err) throw err;
+ files.forEach((file) => {
+ const filePath = path.join(directory, file);
+ if (fs.statSync(filePath).isDirectory()) {
+ replaceMjsOccurrences(filePath);
+ } else {
+ fs.readFile(filePath, "utf8", (err, data) => {
+ if (err) throw err;
+ const result = data.replace(/\.mjs/g, ".js");
+ fs.writeFile(filePath, result, "utf8", (err) => {
+ if (err) throw err;
+ // eslint-disable-next-line no-console
+ console.log(`Updated: ${filePath}`);
+ });
+ });
+ }
+ });
+ });
+}
+
+replaceMjsOccurrences("dist");