streamich / react-use

React Hooks — 👍
http://streamich.github.io/react-use
The Unlicense
41.98k stars 3.16k forks source link

build: support ES modules #2596

Open oblador opened 1 month ago

oblador commented 1 month ago

Description

This package can't be used in a node environment using ESM as it's neither declared as "type": "module" nor does it include .mjs extensions for the files in the module main field.

Since TSC is not able to produce proper ESM files with .mjs extensions I opted to use tsup to compile the ESM files, and I also had to add @swc/core to keep this backwards compatible with the es5 target. I don't think there's much point in supporting back to es5 for an ESM, but I'm keeping it for now to avoid making this a breaking change.

Fixes #2353

Type of change

Checklist