question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 2 years ago
  • Reactions:6
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
devongovettcommented, Aug 10, 2022

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 exports map 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.

1reaction
snowystingercommented, Nov 22, 2022

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 PDT First one will be tonight. Thank you for helping us with this work!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found