Closed adrianmfi closed 1 year ago
Thanks for reporting. Not sure why this is happening and certainly not sure why it's not found by test cases or somewhere else (yet). The only thing that comes to mind that could cause undefined import is in some cases of circular dependency but I'm not sure what would introduce that in 2.10.0. If you can provide a full reproduction in a public git repo that could help get to the bottom of this.
I've tried to make a reproduction at https://github.com/bjornharrtell/jsts-issue-502 but it works as expected no import issues and runs fine outputting the expected LINESTRING (1 1, 2 2)
, so I really need your help with a reproduction.
I spent some some time trying to reproduce minimally, and it turns out that it was my fault, my apologies.
The cause was, as you suggested, a circular import issue, which I inadvertently introduced as part of upgrading. I think the reason why I did not observe the error on v2.9.3 is that I'm using Vite with dependency pre-bundling, where the cached version of jsts@2.9.3 did not have the circular import, or something along those lines. When disabling browser cache, and thus forcing the browser to fetch the newest bundle, I observe the error on v 2.9.3 as well.
Removing the circular import and I no longer get the error.
Thanks for pointing me in the direction of circular imports and once again sorry for the inconvenience!
A quick follow up, this seems to have been caused because I was using
import { GeometryFactory } from 'jsts/org/locationtech/jts/geom';
style imports, but only for dependencies optimized by vite
;
I was able to make it work by excluding jsts in dependency optimization:
optimizeDeps: {
exclude: ['jsts'],
},
But instead changing to
import GeometryFactory from 'jsts/org/locationtech/jts/geom/GeometryFactory';
resolved the issue
Hi, thanks for the awesome work porting jts.
I've just attempted updating from
jsts@2.9.3
tojsts@2.10.0
using npm, and get the following error when loading the module.The import of
LineString
has becomeundefined
:Other imports in the same file is defined:
When using jsts 2.9.3,
LineString
is defined:Any idea what might be the cause?