wkx icon indicating copy to clipboard operation
wkx copied to clipboard

Rewrite as es module

Open mhkeller opened this issue 5 years ago • 4 comments

Hello, When bundling this library with rollup it throws an error because Geometry is being declared after it's being called. This is due to circular dependencies that the current commonjs format doesn't sort out correctly. Rewriting this library as an es module would fix the problem.

mhkeller avatar Sep 24 '18 21:09 mhkeller

(I work with @mhkeller)

I've forked the library so that we're able to use it in our app — our fork is here: https://github.com/Rich-Harris/wkx/tree/esm. The good news is that the dist/wkx.min.js file is now less than half the size — from 63,838 bytes to 30,719. This is because Browserify adds a lot of unnecessary cruft.

All the tests still pass. Let me know if you'd like a PR!

Rich-Harris avatar Sep 24 '18 22:09 Rich-Harris

Any update on this? I might consider making a PR if there was interest.

kylebarron avatar Apr 29 '20 21:04 kylebarron

@Rich-Harris, I want to bundle another package (sequelize), that uses this package. While this issue is outstanding is their any magic/trickery that I can use to tell rollup to replace the require with your fork?

nevermind

I forked sequelize, referenced your wkx fork and rollup still produces a bundle that fails @

util.inherits(Point, geometry);

¯_(ツ)_/¯

ispyinternet avatar Jul 30 '20 20:07 ispyinternet

+1 for solving this issue. I would like to use it in SQL-Geometry visualization in DbGate database client (written in Svelte+rollup)

janproch avatar Jul 17 '22 14:07 janproch