simonwep / pickr

🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
https://simonwep.github.io/pickr
MIT License
4.29k stars 287 forks source link

Update package and build scripts to ESM #336

Open wipeautcrafter opened 5 months ago

wipeautcrafter commented 5 months ago

Issue

When trying to import Pickr in a TypeScript project, the types add an extra .default. This means that instead of Pickr.create, TypeScript exposes Pickr.default.create.

import Pickr from '@simonwep/pickr'

const pickr = Pickr.create({
//                  ^^^^^^ Property 'create' does not exist on type (...)

Solution

Changing the type to module in package.json seems to fix the issue. The build scripts had to be updated to ESM following this change.