concaveman: TypeError: Queue is not a constructor

Hello!

When running version v1.2.0 of concaveman with Webpack (in a vue-cli environment), the following error occurs:

TypeError: Queue is not a constructor
    at findCandidate (index.js:95)
    at concaveman (index.js:65)

In Chrome Debugger, Queue is an object which holds a transpiled ES6 module, and has __esModule and default properties.

Is this a bug in concaveman or my Webpack configuration?

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 29
  • Comments: 16 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry for the late reaction everyone, I was holding back on this because I really don’t like the default hack and planned to fully convert this package to a pure ES module with type: "module" instead. Never got around to it but I will at some point. Released v1.2.1 with the fix.

You can get around this issue by installing tinyqueue as a dependency in your project:

npm install tinyqueue

And then configuring your webpack config with an alias within the resolve object like so:

 resolve: {
        alias: {
            tinyqueue$: require.resolve('tinyqueue/tinyqueue.js')
        }
  },

Hope this helps.

@mourner who at Mapbox is responsible for merging the PR fixing this issue? This issue is a year old, and is a big bug that’s effecting a lot of users.

We manually apply @grassick’s fix for now and it works locally but this bug still breaks our build pipelines.

I had this error but with RBush, and using SvelteKit, which uses Vite. It was fixed with the same thing solution as the PR mentioned above.

if (RBush.default) {
    RBush = RBush.default;
}

I am in contact with Mapbox support about this. The GL JS team is aware but was busy with the v2 release so far.

Thanks for the suggestion @alebinson. I don’t want to introduce another 124 dependencies to our project, so we resolve the dependency via a resolutions block in Yarn’s package.json. Even better of course if you control the repo yourself.

 "resolutions": {
    "@turf/center-of-mass/concaveman": "https://github.com/grassick/concaveman#patch-1"
  },

We’ve caught the issue too. Lost a day of debugging.

I guess a fix would be to switch to ES bundling for this module

Do you mean each client has to do it? Is it possible to fix it once and for everyone to avoid the multiplication of pain (does it really need to export both named and default)?

At least in the short-term, using webpack-chain we monkey patched tinyqueue like so:

// TODO: Track this issue
// https://github.com/mapbox/concaveman/issues/18
config.resolve.alias.set('tinyqueue', require.resolve('tinyqueue/tinyqueue.js'))