Nested `default` exports with using dynamic import
See original GitHub issue@testing-library/user-eventversion: 13.5.0
- Testing Framework and version: Vitest v0.0.106
- DOM Environment: None
Relevant code or config
When using Node’s native dynamic import, nested default is exported, causing the resolving to fail. Related https://github.com/vitest-dev/vitest/issues/243
➜ node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> const a = await import('@testing-library/user-event')
undefined
> a
[Module: null prototype] {
__esModule: true,
default: {
default: {
click: [Function: click],
dblClick: [Function: dblClick],
type: [Function: type],
clear: [Function: clear],
tab: [Function: tab],
hover: [Function: hover],
unhover: [Function: unhover],
upload: [Function: upload],
selectOptions: [Function: bound selectOptionsBase],
deselectOptions: [Function: bound selectOptionsBase],
paste: [Function: paste],
keyboard: [Function: keyboard]
},
specialChars: [Getter]
},
specialChars: {
arrowLeft: '{arrowleft}',
arrowRight: '{arrowright}',
arrowDown: '{arrowdown}',
arrowUp: '{arrowup}',
enter: '{enter}',
escape: '{esc}',
delete: '{del}',
backspace: '{backspace}',
home: '{home}',
end: '{end}',
selectAll: '{selectall}',
space: '{space}',
whitespace: ' ',
pageUp: '{pageUp}',
pageDown: '{pageDown}'
}
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:18 (10 by maintainers)
Top Results From Across the Web
node.js - export default <Class> exports double nested default
I solved my problem by creating a variable inside the class I want to use my import. something like this: export default class ......
Read more >Nested Imports in Meteor - zodern
Nested imports should not be confused with dynamic imports. Dynamic imports delay downloading a file until it is needed. In contrast, the files...
Read more >Demistifying webpack's 'import' function: using dynamic ...
In this article we will learn about demistifying webpack's 'import' function: using dynamic arguments. Although it is a popular selling point ...
Read more >Dynamic import() Expressions in TypeScript - Marius Schulz
TypeScript 2.4 added support for dynamic import() expressions, which allow you to asynchronously load and execute ECMAScript modules on demand.
Read more >Dynamic imports in Next.JS - Medium
Dynamic imports, unlike regular imports, are flexible about when and how the modules are imported, hence improving the page load time. In ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Resolved in v14.0.0-beta.4. I hope the solution “just works” for everybody.
This is pure ESM Node without any transpilers: https://stackblitz.com/edit/node-mucfca?file=index.js
I’m not sure if
exports.defaultis correct representation of default export. Isn’t itmodule.exports? Maybe you need to update your bundling proccess?I think bundlers tried to support this way of exporting default, but official implementation doesn’t. Babel has a lot of experimental things that didn’t end up in Node/browsers and the whole point of using babel is to make it run everywhere 😄