Open smallsaucepan opened 1 month ago
Hi! Thanks for the suggestion and for supporting the package!
If possible, could you split it into two PRsβone to fix the type export issue and another to add CJS support? This would make the review process easier.
Sure thing π Will do the smaller type export one first.
Oh, actually just saw #8, which had a similar goal to this issue. That PR was merged in e079fa8 but then rolled back some months later by 7bfaa6c.
Did something go wrong? Couldn't find any chatter about the reason.
The PR was merged but rolled back before publishing a new version on npm. It references a PR in another repository that hasnβt been merged. I still have doubts about the ideal solution and want to be cautious with breaking changes.
Ah, understand. What I have in mind is quite similar to @vschroeter's PR, and a lot of the discussions they're having on the vite PR Turf has had too.
Appreciate you being cautious, and I certainly don't want to ruin anyone's day. To test we can implement a bunch of dummy clients and make sure we don't introduce any errors. Do you get any stats on who is using the library? Node or browser versions?
One thing I'd like to know more about is the existing "umd": "..."
entry in exports. Not seen that before, and can't find it documented anywhere. If I understand this documentation it would act as a subpath should someone try to import * as whatever from "polyclip-ts/umd"
? Do you recall which client/s that was intended for?
Hi @luizbarboza. Do you have any thoughts on the above?
@smallsaucepan Honestly, Iβm not entirely sure what is causing the error when resolving types.
The UMD bundle is intended for legacy environments and can be used via a CDN, as explained in the README.
A previous PR that was reverted had removed the UMD entry, but itβs important to keep it for backward compatibility. Could you submit a PR to fix the issue while preserving the UMD entry?
Honestly, Iβm not entirely sure what is causing the error when resolving types.
@luizbarboza it's a couple of things. The immediate problem solved below is that typescript tools will (without further config) look for typedefs in the same directory as dist/index.js. But the index.d.ts is currently in the types/ directory. That's why we get errors in rows 3. and 4. below.
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β β "polyclip-ts" β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β node10 β π’ β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β node16 (from CJS) β β No types β
β β β οΈ ESM (dynamic import only) β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β node16 (from ESM) β β No types β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β bundler β β No types β
βββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ
I have a four line PR that leaves umd untouched and gets you to this:
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β β "polyclip-ts" β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β node10 β π’ β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β node16 (from CJS) β β No types β
β β β οΈ ESM (dynamic import only) β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β node16 (from ESM) β π’ (ESM) β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β bundler β π’ β
βββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ
No support for CJS require, same as current library. It can be added though that's a bit more involved. Happy to go with your preference.
Actually just remembered your comment above about adding CJS support separately. Will create a PR just for fixing up ESM types π
Thanks for merging that @luizbarboza. Are you planning to release 0.16.7 with just this PR, or do you want to do the CJS generation as well first?
Version 0.16.7 will be released with just this PR, leaving support for CJS for a later new version.
Wonderful. Thank you!
Hi @luizbarboza. We're quite keen to use polyclip-ts over in Turfjs. However having some issues gettings the types imported e.g.
One fix would be to flesh out the exports section of polyclip-ts/package.json, so would be happy to prepare a PR for that. However, without packaging CJS version of the library as well, the best we could hope for from arethetypeswrong would be:
Would you like a PR that will generate and export CJS also? Or do you prefer to stick with ESM only?
Thanks for maintaining the package!