Open davidklein147 opened 6 months ago
I have not worked with react but in Browserify you can include browserify-fs in your build which basically takes over for the fs module. We do that in our own geopackage-viewer project here: https://github.com/ngageoint/geopackage-viewer-js/blob/main/package.json I would imagine there is a way to shim the fs module with react or however you are building, but I do not know how off the top of my head.
@danielbarela Thank you very much for your response
I found a solution for this by adding a configuration to the next.config.js file to tell next webpack to ignore fs in is not in server side
/** @type {import('next').NextConfig} */
const nextConfig = {
...,
webpack(config, { isServer }) {
config.resolve.fallback = {
fs: isServer ? "true" : false,
}
return config
},
}
module.exports = nextConfig
Description:
In my next.js project I use to display maps with the react-leaflet library, in some cases I need to import the tile layer from a gpkg file, to solve this I found your library which seems to solve the challenge. But when trying to import @ngageoint/leaflet-geopackage in the Next.js environment, an error occurs due to the library trying to access the fs module, which is not available in the browser environment. This prevents the application from building successfully.
Expected Behavior
from your readme file of @ngageoint/leaflet-geopackage lib
So the library should import successfully in browser without any errors, allowing the application to build correctly.
Actual Behavior
An error occurs during the build process due to the library attempting to access the
fs
module, which is not available in the browser environment.Example Code
NOTE: related to #2 with out finding a example how to use this lib in "react", this is my invention how to use it, I`m not sure that this is correct, but due the issue I can't even import it, so I can't test if it works either.
Error getting:
so importing this line:
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module: ./node_modules/@ngageoint/leaflet-geopackage/leaflet-geopackage.js ./components/maps/map-shows.tsx