AlexLavoie42 / Nuxt-Mapbox

Elegant Mapbox integration with Nuxt
81 stars 11 forks source link

Uncaught SyntaxError #49

Closed Me-Phew closed 1 year ago

Me-Phew commented 1 year ago

I'm getting this error in the browser after adding the module:

plugin.client.mjs:2 Uncaught SyntaxError: The requested module '/_nuxt/node_modules/mapbox-gl/dist/mapbox-gl.js?v=82da2922' does not provide an export named 'default' (at plugin.client.mjs:2:10)

Nuxt version 3.6.3 with Nitro 2.5.2

AlexLavoie42 commented 1 year ago

Fixed in #50 Be sure to update nuxt to 3.6.5 which was just released. There seems to have been a bug with component importing in 3.6.4.

farzadso commented 1 year ago

@AlexLavoie42 Is adding nuxt.options.alias['mapbox-gl'] = 'mapbox-gl' also a step in fixing this issue?

AlexLavoie42 commented 1 year ago

Yes, see https://github.com/nuxt/nuxt/issues/19426 as it seems to be related and that is where I got the fix. The root issue is that in some projects plugin.client.mjs doesn't get bundled causing the import issue. The alias I'd just a hack to force it into getting bundled.

farzadso commented 1 year ago

@AlexLavoie42 I did the same here : https://github.com/nuxt-community/nuxt-logrocket/blob/master/src/module.ts#L148 But it didn't have any effect whatsoever.

AlexLavoie42 commented 1 year ago

The alias would need to be for logrocket itself since that is the import causing the error, not the module. As you can see in my fix I did mapbox-gl as the alias not nuxt-mapbox