astoilkov / use-local-storage-state

React hook that persists data in localStorage
MIT License
1.17k stars 41 forks source link

Make change exporting both cjs and esm #72

Closed dwjohnston closed 1 week ago

dwjohnston commented 3 weeks ago

Addresses #71

  1. Creates a second TSconfig to compile to CJS
  2. Outputs the compiled code to dist/esm and dist/cjs
  3. I've also removed yarn.lock from the .gitignore. It's a good idea to version control this file -see https://stackoverflow.com/questions/44206782/do-i-commit-the-package-lock-json-file-created-by-npm-5

In terms of testing, I ran into issues using the npm link approach - essentially the problem is two versions of React end up existing.

So I copied pasted the compiled CJS over to the reproduction and checked that it works there.