@jakebailey says:
...this is a runtime issue with TypeScript's CJS import helpers, so the issue should be files on TypeScript.
π Search Terms
dynamic import default wrapped
π Version & Regression Information
"typescript": "^5.5.3"
β― Playground Link
https://stackblitz.com/edit/typescript-dynamic-import-issue?file=tsconfig.json,README.md%3AL6
And run this: $ npx tsc --outDir build && node build/bar.js
π» Code
foo.ts
export default function MyFoo() {
return 'foo';
}
bar.ts
(async function main() {
const foo = await import('./foo.js');
console.log(foo);
})();
tsconfig.json
{
"compilerOptions": {
"module": "nodenext"
},
"include": ["src/**/*"]
}
π Actual 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
Expected behavior is that it produces the following output:
[Module: null prototype] {
__esModule: true,
default: [Function: MyFoo]
}
Additional information about the issue
Initially raised here tsconfig/bases#273
@jakebailey says:
π Search Terms
dynamic import default wrapped
π Version & Regression Information
"typescript": "^5.5.3"β― Playground Link
https://stackblitz.com/edit/typescript-dynamic-import-issue?file=tsconfig.json,README.md%3AL6
And run this:
$ npx tsc --outDir build && node build/bar.jsπ» Code
foo.tsbar.tstsconfig.json{ "compilerOptions": { "module": "nodenext" }, "include": ["src/**/*"] }π Actual behavior
This produces the following output:
π Expected behavior
Expected behavior is that it produces the following output:
Additional information about the issue
Initially raised here tsconfig/bases#273