mapbox / mapnik-pool

manage a pool of mapnik map instances
Other
20 stars 22 forks source link

Trouble using with babel #14

Closed charandas closed 6 years ago

charandas commented 6 years ago

https://github.com/mapbox/mapnik-pool/blob/eeb37f8456225fe17b8ad519ee4ce3b2ade3be23/index.js#L14

Anybody knows why this anti-pattern exists in the first place:

2017-09-29T21:29:52.839Z [Error] Class constructor Pool cannot be invoked without 'new' TypeError: Class constructor Pool cannot be invoked without 'new'
    at Object.fromString (/src/node_modules/mapnik-pool/index.js:14:20)
    at new PostgisSource (/src/node_modules/tilelive-postgis/src/index.js:25:27)
    at Object.<anonymous>.tilelive.load (/src/node_modules/@mapbox/tilelive/lib/tilelive.js:97:5)
charandas commented 6 years ago

This would do it:

https://github.com/mapbox/mapnik-pool/blob/master/package.json#L26

Since v2 to v3 has had many breaking changes.

I am still amazed how it works when Babel is out of the loop. FYI I am only using Babel because Jest uses it by default, and I want to write some tests on my tile server code.

charandas commented 6 years ago

Previously, this used to rely on:

https://github.com/coopernurse/node-pool/blob/6c98fa9163bbe35b683ffc2b55ac741d02956096/lib/generic-pool.js#L125

charandas commented 6 years ago

Never mind. The package correctly uses tilde to specify generic-pool version.

https://nodesource.com/blog/semver-tilde-and-caret/

package authors have been pinning to versions within a fixed major and minor pair but a floating patch version.

I am not sure why npm@5 is getting me v3 of generic-pool with the way the deps are setup currently.

charandas commented 6 years ago

Figured the issue was due to another dep requiring 3.1.8 for generic-pool. So I had to look deeper for the correct dependency:

cat node_modules/mapnik-pool/node_modules/generic-pool/package.json