I am trying to integrate an existing library in my new codebase using typescript
and Bun
. i am facing an issue where this library is requiring modules in code asynchronously, like follows :
let target = require(AppRoot + targetName);
target.execute(targetTask);
so passing in the targetName
, it can require the module which is a default exported object (usually an instantiated class). This was working fine when i was using this library in JS but when switching to Typescript
the target
became an Object with default being the actual instantiated class :
// in Javascript
Target {
execute : [Function]
}
// in Typescript
Target {
default : {
execute : [Funtion]
}
}
This change breaks the entire library of course as it relies on reading files that way. I am not suer if this is a Bun
or Typescript
issue, but is there a way to bypass forcing the default
when importing for a specific library
Note: I already have esModuleInterop
set to true in my tsconfig
which according to chatgpt is the only hand-off solution