soywod / react-pin-field

📟 React component for entering PIN codes.
https://soywod.github.io/react-pin-field/
MIT License
413 stars 24 forks source link

Building with vite.js #29

Closed sveisvei closed 3 years ago

sveisvei commented 3 years ago

Building this with vite.js creates a problem when not targetting commonjs.

The source of the problem is form "index.js" and Object.defineProperty(exports, "__esModule", { value: true });.

The browser error is: Uncaught ReferenceError: exports is not defined

I think changing the "module" in tsconfig from "commonjs" to "umd" might fix this, or even better move to a more broad target https://tsdx.io/ - e.g. like headlessui: https://github.com/tailwindlabs/headlessui/blob/develop/scripts/build.sh#L8

soywod commented 3 years ago

This could definitely help: https://tsdx.io/. I will check this weekend and let you know. Thanks for the feedback!

sveisvei commented 3 years ago

@soywod I did fork and tested tsdx on your repos locally, and it seemed to work out of the box.

soywod commented 3 years ago

Awesome @sveisvei! Maybe consider proposing a PR? So you will be part of the contributors :smiley:

soywod commented 3 years ago

BTW, I think it is sth to replicate on https://github.com/soywod/pin-field.

sveisvei commented 3 years ago

@soywod I did what I had the time to do - you can test them - or do something similar yourself. Let me know if I can help more later.

soywod commented 3 years ago

@sveisvei sorry I read your message after reviewing your PR https://github.com/soywod/pin-field/pull/1. I will adapt what you did and merge ASAP. Thanks for the initiative :tada:

soywod commented 3 years ago

I guess it should work now thanks to https://github.com/soywod/react-pin-field/pull/30, feel free to reopen if you still have issues.