🐛 Bug report
Current Behavior
VisuallyHidden component causes error, because default import returns an object instead of a component:
import VisuallyHidden from '@reach/visually-hidden'
console.log(VisuallyHidden)
// {
// default: {
// ... component here
// }
// }
Expected behavior
Default import should return a component:
import VisuallyHidden from '@reach/visually-hidden'
console.log(VisuallyHidden)
// {
// ... component here
// }
Reproducible example
Fresh Next.js install with only Typescsript and @reach/visually-hidden dependencies.
GitHub Repository
Suggested solution(s)
When I edit source of visually-hidden.development.js manually and change last line exports.default = to module.exports = , then it works. It's either build issue or my tsconfig issue.
Edit: It seems that build files are missing Object.defineProperty(exports, '__esModule', { value: true }); line. Add this line to source solves the problem as well. I've checked tsdx, and it seems to be configured correctly (i.e. respecting esModuleInterop settings from tsconfig.json)
Additional context
- It only affects components with default exports only (i.e. VisuallyHidden). Other components works fine (e.g. Menu).
- I tried update tsconfig, but I'm using the official one from Next.js without any modification.
- The bug appeard after 0.7.0, when codebase was migrated to Typescript.
- I tried to interop default export manually and noticed, this only happens on server (i.e. running in Node.js).
Your environment
| Software |
Name(s) |
Version |
| Reach Package |
@reach/visually-hidden |
0.7.3 |
| Typescript |
|
3.7.5 |
🐛 Bug report
Current Behavior
VisuallyHiddencomponent causes error, because default import returns an object instead of a component:Expected behavior
Default import should return a component:
Reproducible example
Fresh Next.js install with only
Typescsriptand@reach/visually-hiddendependencies.GitHub Repository
Suggested solution(s)
When I edit source of
visually-hidden.development.jsmanually and change last lineexports.default =tomodule.exports =, then it works. It's either build issue or my tsconfig issue.Edit: It seems that build files are missing
Object.defineProperty(exports, '__esModule', { value: true });line. Add this line to source solves the problem as well. I've checked tsdx, and it seems to be configured correctly (i.e. respectingesModuleInteropsettings fromtsconfig.json)Additional context
Your environment