Unable to load @react-aria/textfield as ESM module
See original GitHub issue🐛 Bug Report
Starting with version 3.5.1, the contents of @react-aria/textfield/dist/module.js seems to have become garbled. The file at version 3.5.0 looks good and can be correctly loaded as an ESM module.
🤔 Expected Behavior
The file to be loaded correctly, for example, by jest.
😯 Current Behavior
The module is not understood by node:
SyntaxError: The requested module '@react-aria/textfield' does not provide an export named 'useTextField'
💁 Possible Solution
🔦 Context
Trying to run unit tests against a component that depends on @react-aria/textfield.
💻 Code Sample
🌍 Your Environment
| Software | Version(s) |
|---|---|
| react-spectrum | 3.5.2 |
| Browser | Firefox |
| Operating System | macOS |
🧢 Your Company/Team
🕷 Tracking Issue (optional)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:18 (13 by maintainers)
Top Results From Across the Web
ESM modules failed to load #30871 - nodejs/node - GitHub
v13.3.0: OSX: 10.13.6: I have a package.json which amounts to what is the following. { "name": "dyo", "type": "module", ...
Read more >Unable to import ESM .ts module in node - Stack Overflow
Updated on 14.09.2022. I've created a repository with the necessary settings to run esm directly via ts-node or using tsc and running the ......
Read more >Using ECMAScript modules (ESM) with Node.js
Learn about using ES modules in Node.js today and get a closer look at how you can migrate your codebase to make use...
Read more >How we employed the new ECMAScript Module Support in ...
In regards to performance, with ESM import you can selectively load only the pieces you need. This can save you runtime memory or...
Read more >Modules • JavaScript for impatient programmers (ES2022 ...
Modules are meant to be loaded asynchronously. That's a crucial requirement for browsers, where code can't wait until a module has finished downloading....
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

You could use a CJS require in the meantime, or transpile your code to CJS. Node ESM has never really been supported by React Aria. It may have worked by accident sometimes due to node’s flaky interop, but we don’t currently test against it.
If we wanted to support it, I guess using an
exportsmap would be the right way, though I suspect some other things might be broken as well. Node’s ESM is quite strict compared with bundlers/transpilers - for example, relative imports must use file extensions.I’ve merged this branch, we’re going to have it in nightlies for a while to make sure we haven’t broken anything. Our targeted release date for this is January. Please try it out on the nightlies which publish at 2am PDT.
"0 9 * * *" # 02:00 PDTFirst one will be tonight. Thank you for helping us with this work!