Skip to content

A local-first personal finance app

Fix esm error on windows (#566)

Michael Clarke1a694a55429
diff --git a/src/app-gocardless/bank-factory.js b/src/app-gocardless/bank-factory.js
index 6f37ffdc00..33d6a4ec89 100644
--- a/src/app-gocardless/bank-factory.js
+++ b/src/app-gocardless/bank-factory.js
@@ -1,6 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
-import { fileURLToPath } from 'node:url';
+import { fileURLToPath, pathToFileURL } from 'node:url';
import IntegrationBank from './banks/integration-bank.js';
@@ -14,7 +14,8 @@ async function loadBanks() {
const imports = await Promise.all(
bankHandlers.map((file) => {
- return import(path.resolve(banksDir, file)).then(
+ const fileUrlToBank = pathToFileURL(path.resolve(banksDir, file)); // pathToFileURL for ESM compatibility
+ return import(fileUrlToBank.toString()).then(
(handler) => handler.default,
);
}),
diff --git a/upcoming-release-notes/566.md b/upcoming-release-notes/566.md
new file mode 100644
index 0000000000..0b7fca0b1d
--- /dev/null
+++ b/upcoming-release-notes/566.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [MikesGlitch]
+---
+
+Fix ESM bug on Windows when loading gocardless banks