-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed as not planned
Closed as not planned
Copy link
Labels
ExternalRelates to another program, environment, or user action which we cannot control.Relates to another program, environment, or user action which we cannot control.Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Milestone
Description
@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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ExternalRelates to another program, environment, or user action which we cannot control.Relates to another program, environment, or user action which we cannot control.Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug