sudodoki/copy-to-clipboard

not es-module compliant

vdegenne opened this issue · 2 comments

Hey nice package, but unfortunately not ESModule-compliant.

You use the import syntax in your documentation, and you even provide TypeScript types, which is a bit misleading because in the hood your script is CommonJS. That's bad practice.
I am having a hard time integrating your lib into my TypeScript project.

You may want to consider turning your script into an ES Module anyway. Modern browsers support modules now it's safe, that means your package wouldn't technically need any compilation, you could just load it into the browser in a module context.
But you still can use it in a compilation process, most transpilers and bundlers understand modules now.

Technically you wouldn't need much headache, just adding "type": "module" in your package.json and changing module.exports = ... to export default ... I guess.

oeed commented

This would be great. It's causing a few headaches getting it to work with Vite. See #129

@oeed I opened a PR but this repo is dead. Better fork it or find another one..