mapbox / polylabel

A fast algorithm for finding the pole of inaccessibility of a polygon (in JavaScript and C++)
Other
1.44k stars 151 forks source link

New update breaks Webpack build #60

Closed TimonLukas closed 4 years ago

TimonLukas commented 4 years ago

Hello! While updating the dependencies of one of our apps we just noticed that polylabel got an update. Sadly this update breaks the module for our frontends, because with tinyqueues export syntax the imported module is no longer the class constructor, which instead lies in require('tinyqueue').default. This is the error message we are getting:

Uncaught TypeError: Queue is not a constructor

We've fixed it for now by pinning tinyqueue to version 1.2.2, but this isn't a great solution. Any tips on how we could fix this? Or is there potentially any way for you to fix this on your side? (e. g. by checking if a default property exists on the import)

Thank you!

mourner commented 4 years ago

Oh dear, I hate Webpack so much. Pushed a temporary fix in v1.0.5. Will migrate the project to ES / modules in v2.

TimonLukas commented 4 years ago

Thank you or the very quick fix, and for the heads-up! :)

jonhermansen commented 4 years ago

I ran into an issue with the most recent release, 1.0.5. It happened due to my app's dependency chain:

$ npm ls tinyqueue
my-project@1.2.3 /Users/jhermansen/Desktop/my-project
└─┬ @amcharts/amcharts4@4.5.12
  └─┬ polylabel@1.0.5
    └── tinyqueue@2.0.3

I think it was caused by 6854a05e221fac42b9e025cbf356b2a057f212aa while upgrading to tinyqueue 2.x, which has this bug https://github.com/mourner/tinyqueue/issues/12

My application needs to support IE 11 and so inadvertently it started bundling some JS code that was trying to use ES6 classes, which causes IE to stop loading my app entirely :(

I hope I don't come across as complainy. Thank you for building cool open source stuff, that I didn't even know I was using under the hood until today. 😃 I just thought this information may be helpful in case anyone else runs into it.

In my case, I was able to fix the issue by committing a package-lock.json file that pins polylabel to v1.0.2 (and consequently, tinyqueue to v1.2.3)