Hello,
I working on an app handling GIS shape files. To support shape files, I am using a package called shpjs which in turn uses jszip. Both of them depend on nodejs Buffer.
I am trying to use the node-stdlib-browser
package to polyfill Buffer
but have not been successful.
Please see my tsup config below:
import { defineConfig } from "tsup";
//@ts-ignore
import nodeStdLibBrowswerPlugin from "node-stdlib-browser/helpers/esbuild/plugin";
import { default as stdLibBrowser } from "node-stdlib-browser";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
export default defineConfig({
platform: "browser",
esbuildOptions: (options, context) => {
options.inject = [require.resolve("node-stdlib-browser/helpers/esbuild/shim")];
options.define = {
global: "global",
process: "process",
Buffer: "Buffer",
};
},
esbuildPlugins: [nodeStdLibBrowswerPlugin(stdLibBrowser)],
inject: [require.resolve("node-stdlib-browser/helpers/esbuild/shim")],
define: {
global: "global",
process: "process",
Buffer: "Buffer",
},
});
But still I get an error in JSZip.
Am I setting up polyfill correctly?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too