mbloch / mapshaper

Tools for editing Shapefile, GeoJSON, TopoJSON and CSV files
http://mapshaper.org
Other
3.8k stars 536 forks source link

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

Open skudev opened 2 days ago

skudev commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

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