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

Can I use mapshaper in a React vite app? #665

Open
skudev opened this issue Nov 29, 2024 · 2 comments
Open

Can I use mapshaper in a React vite app? #665

skudev opened this issue Nov 29, 2024 · 2 comments

Comments

@skudev
Copy link

skudev commented Nov 29, 2024

Hi,

when I try to use mapshaper in my React vite app, I get this error message

__vite-browser-external:crypto:3 Uncaught Error: Module "crypto" has been externalized for browser compatibility. Cannot access "crypto.randomFillSync" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
at Object.get (__vite-browser-external:crypto:3:11)
at (zipcrypto.js?v=93aa1cb2:10:13)
at __require (zipcrypto.js?v=93aa1cb2:3:50)
at zipcrypto.js?v=93aa1cb2:126:16

Is mapshaper meant to be used in a React vite app? I am migrating a React project which used mapshaper-es with some webpack configuration. But as mapshaper-es has beeen deprecated I would love to migragte to mapshaper if possible.

@skudev
Copy link
Author

skudev commented Nov 29, 2024

I have tried to polyfill crypto and other node modules but still get this error:
Uncaught Error: Dynamic require of "iconv-lite" is not supported
at chunk-HG6TCYAD.js?v=08f0e83c:19:9
at mapshaper.js:3742:7
at node_modules/mapshaper/mapshaper.js (mapshaper.js:46704:4)
at __require2 (chunk-HG6TCYAD.js?v=08f0e83c:25:50)
at mapshaper.js:46704:4

Would you have the possibility to provide a browser build of mapshaper?

@skudev
Copy link
Author

skudev commented Nov 29, 2024

The project that I am migrating is using some of you geoprocessing commands like
erase,
simplify,
dissolve2,
clean,
proj,
explode,
exportShpFromGeojson,
exportGeojsonFromShp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant