Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing CJS #39

Closed
dnohr opened this issue Apr 22, 2023 · 8 comments
Closed

Missing CJS #39

dnohr opened this issue Apr 22, 2023 · 8 comments
Labels

Comments

@dnohr
Copy link

dnohr commented Apr 22, 2023

Hi,

Thank you for working on the project, I really appreciate it.

I was updating all my libraries as usual, but it seems like the new v4.0.1 doesn't work with Common JS anymore. Is this intentional or is it a bug? I had to roll back to version 3.0.0, which works as intended.

Thank you!

@mourner
Copy link
Owner

mourner commented Apr 22, 2023

Ah, yeah, I forgot to mention that I dropped the CommonJS entry point — I did the same with Flatbush a year ago and no one mentioned it. Is it still a deal breaker now that Node versions which don't support ESM have long reached End of Life?

@dnohr
Copy link
Author

dnohr commented Apr 22, 2023

Thank you for replying so quickly!

I am utilizing this module in larger web projects, which makes it difficult to alter the codebase to ESM. Although I aimed to use the updated version, I'm uncertain about the effort required to make it compatible with both CJS and ESM.

It would have been much simpler for everyone if imports worked immediately within CommonJS. Thanks.

@ChrisLahaye
Copy link

Would it be possible to support CommonJS?

@dnohr
Copy link
Author

dnohr commented Mar 2, 2024

This is still a wish for 2024, as it's still the fastest algorithm for its task of doing nearby searches. If you have any guidance for enabling CommonJS without additional work from your side, I'm all ears. Thank you again for working on the library!

@mourner
Copy link
Owner

mourner commented Mar 2, 2024

@dnohr the easiest approach is to just use KDBush v3 and not upgrade further. Another option is to use a dynamic import within a CommonJS module — await import('kdbush').

@dnohr
Copy link
Author

dnohr commented Mar 6, 2024

@mourner: Yeah, I'm using v3 now, but since I'm using the ncu update script, I manually need to downgrade it to v3 again. It's not a big thing, but I still wish CommonJS was supported in the newest versions. Do you have any working examples of using kdbush with dynamic import? I tried, but it keeps failing within my CommonJS project.

@mspanc
Copy link

mspanc commented May 13, 2024

It seems it causes some issues with TypeScript. It tends to rewrite imports in such a way that you need to use hacks to use the library: microsoft/TypeScript#43329 (comment)

Given that it seems it would have been nicer to have CJS entrypoint.

@mourner
Copy link
Owner

mourner commented Jul 1, 2024

Closing this issue since I no longer intend to support CommonJS in any of my projects. Please let this thing die already, the faster everyone moves on the better for the JS ecosystem 🙏

@mourner mourner closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants