Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the library supports server side rendering? #188

Closed
abdurrahmanseyidoglu opened this issue Dec 18, 2023 · 4 comments · Fixed by #206
Closed

Does the library supports server side rendering? #188

abdurrahmanseyidoglu opened this issue Dec 18, 2023 · 4 comments · Fixed by #206
Labels
bug Something isn't working has workaround

Comments

@abdurrahmanseyidoglu
Copy link

I'm trying to use it inside Vue3 SSR with inertia but I'm getting the following error on build

import { GoogleMap, InfoWindow, Marker, MarkerCluster } from "vue3-google-map";
         ^^^^^^^^^
SyntaxError: Named export 'GoogleMap' not found. The requested module 'vue3-google-map' is a CommonJ
S module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'vue3-google-map';
const { GoogleMap, InfoWindow, Marker, MarkerCluster } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

Node.js v18.18.2

this error only happens when building the application for SSR.

@HusamElbashir
Copy link
Collaborator

I'd say SSR was never a focus for this library and in any case you can only load the Google script on the client as far as I can tell. I'd say wrap your map with an async component or use whatever mechanism your framework provides to ensure your map is only loaded client side.

@HusamElbashir HusamElbashir added the question Further information is requested label Jan 19, 2024
@HusamElbashir
Copy link
Collaborator

Hi

As a workaround you can add this to your vite.config.js.

ssr: {
  noExternal: ['vue3-google-map']
}

I'll hopefully release a fix for this in the coming days.

@HusamElbashir HusamElbashir added bug Something isn't working has workaround and removed question Further information is requested labels Jan 29, 2024
@aKzenT
Copy link

aKzenT commented Feb 29, 2024

Is there an update on this issue? I'm seeing the same problem and would like to avoid the workarround if possible.

@HusamElbashir
Copy link
Collaborator

Fixed in v0.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants