Open tangzijun opened 1 year ago
To decode geobuf with a "manual" fetch I use this:
import geobuf from "geobuf";
import Pbf from "pbf";
function getCompressedData(geobufFileUrl) {
fetch(geobufFileUrl)
.then((response) => response.arrayBuffer())
.then((buffer) => {
const geoJsonData = geobuf.decode(new Pbf(buffer));
createMap(geoJsonData);
});
}
I am facing the same issue when the code is minified with webpack. I suppose that this is the reason:
My workaround at the moment is to use the Terser webpack plugin to ignore geobuf when minifying the code:
npm i -D terser-webpack-plugin
// webpack.config.js
module.exports = {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({ exclude: /node_modules\/geobuf/ })
],
}
}
When I execute geobuf.decode, an error is reported: