-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Describe the bug
I have a electron-vite project in which I'm trying to setup a notification server for the payment terminal. My problem is that I cannot call new NexoCrypto()
constructor, because the module is not exported properly. This is how it looks in my code:
import NexoCrypto from '@adyen/api-library/lib/src/security/nexoCrypto';
console.log(NexoCrypto); // logs "{ default: [class NexoCrypto] }", but according to the d.ts files this should be just "[class NexoCrypto]"
// new NexoCrypto(); // fails: "NexoCrypto" is not a constructor.
new NexoCrypto.default() // works at runtime, but typescript complains that 'default' doesn't exist.
For context, this is the transpiled code outputted from electron-vite - this import becomes a require
in my code:
const NexoCrypto = require("@adyen/api-library/lib/src/security/nexoCrypto");
I also noticed that when I use import * as NexoCrypto from '@adyen/api-library/lib/src/security/nexoCrypto';
, the module gets logged as
[Object: null prototype] [Module] {
default: { default: [class NexoCrypto] }
}
(notice the doubled default
in the module object).
I don't have this problem in any other imports from the adyen library - only for NexoCrypto, though I think it's because all other models I use are named exports.
Obviously, I don't have this problem when importing any other library in the project, either via default import or a named one.
To Reproduce
- Create a new electron-vite project (https://electron-vite.org/guide/#scaffolding-your-first-electron-vite-project)
- Try to import
NexoCrypto
in the electron main process.
Expected behavior
Exported module does not have a duplicate default
key. I can use the module without going against typescript.
Desktop (please complete the following information):
- OS: Mac
- Node Version:
v20.18.1
- NPM Version: I use
pnpm
, it's version is 9.7.1
Additional context
Add any other context about the problem here.