NTag / dotted-map

Create futuristic SVG maps, Tron-like, filled with dots or hexagons
https://ntag.fr/tron-like-maps/
MIT License
115 stars 23 forks source link

Importing in a project with Vite + React results in __vite_ssr_import_5__.default is not a constructor #13

Closed th0th closed 5 months ago

th0th commented 6 months ago

Hey, first, thanks for making this available 💐

I am trying to use this in a Vite React project, but when I import with

import DottedMap from "dotted-map";

I get this error:

__vite_ssr_import_5__.default is not a constructor

Any idea what might be the cause?

NTag commented 6 months ago

Arf I already saw this error, I think the library isn't greatly bundled…

Can you try to do:

import DottedMapRaw from "dotted-map";

const DottedMap = DottedMapRaw.default;

and see if it works better?

th0th commented 6 months ago

Arf I already saw this error, I think the library isn't greatly bundled…

Can you try to do:

import DottedMapRaw from "dotted-map";

const DottedMap = DottedMapRaw.default;

and see if it works better?

Thanks for the quick reply. But unfortunately, it doesn't work. It results in this typescript error:

TS2339: Property default does not exist on type typeof DottedMap
NTag commented 6 months ago

Hum actually I just tested a blank JS Vite + React project, and I am able to use as expected the library. You can see the "demo project" here: https://github.com/NTag/demo-dotted-map-vite/blob/main/src/App.jsx

To help you further more I'd need more code, or ideally a repo example.

th0th commented 5 months ago

The repo I am working on is way too complex to simplify and share 😅 I went for a workaround and directly copied the functions I needed from the file and put it in a file in the project, and imported from there. So, I think we can close this issue. And once again, thank you for making this, and for your time on this issue, too! 💐

NTag commented 5 months ago

Alright, I understand, glad you have something working in the end 👌 .