antonioru / beautiful-react-hooks

🔥 A collection of beautiful and (hopefully) useful React hooks to speed-up your components and hooks development 🔥
https://antonioru.github.io/beautiful-react-hooks/
MIT License
8.07k stars 570 forks source link

ESM modules import does not working #421

Open zbinlin opened 3 months ago

zbinlin commented 3 months ago

To Reproduce Steps to reproduce the behavior:

  1. Create new npm project: npm init --yes, and install beautiful-react-hooks.
  2. Add "type": "module" to package.json.
  3. Create an index.js file: import "beautiful-react-hooks/useAudio".
  4. Run node index.js, see error: SyntaxError: Cannot use import statement outside a module.
antonioru commented 2 months ago

hey @zbinlin ,

thanks for opening this issue, I've tried to reproduce as you suggested and indeed, the package turns out to be unusable.

This is caused by an incorrect exports management in the package.json that is auto-generated during the build phase.

Please, if you like, try to propose a PR to fix the problem, it would be nice to have you among the contributors... If you can't manage it, no problem, I'll try to fix it as soon as possible

In the meantime, thanks a lot