Repro
Runnable repro: https://stackblitz.com/edit/markl-ts-jest-repro-gbovnq?file=README.md
Relevant files:
foo.ts
export default function MyFoo() {
return 'foo';
}
bar.ts
(async function main() {
const foo = await import('./foo.js');
console.log(foo);
})();
tsconfig.json
{
"extends": ["@tsconfig/node20/tsconfig.json"],
"include": ["src/**/*"]
}
Actual vs Expected behavior
const foo = await import('../src/foo');
console.log(foo);
This produces the following output:
[Module: null prototype] {
__esModule: true,
default: { default: [Function: MyFoo] }
}
Expected behavior is that it produces the following output:
[Module: null prototype] {
__esModule: true,
default: [Function: MyFoo]
}
(stackblitz runs on node 18, but this reproduces exactly on LTS (20) as well)
Thanks!