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

Feature: Browser-compatible version #16

Open
Techn1c4l opened this issue Jul 22, 2023 · 1 comment
Open

Feature: Browser-compatible version #16

Techn1c4l opened this issue Jul 22, 2023 · 1 comment
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@Techn1c4l
Copy link

Techn1c4l commented Jul 22, 2023

While using this package in browsers despite not using streams, I'm getting errors since Buffer and process are not defined in this environment.

ReferenceError: Buffer is not defined
    at node_modules/duplexify/index.js (index.js:6:21)
    at __require2 (chunk-62VDRKYJ.js?v=80dff520:19:50)
    at node_modules/pumpify/index.js (index.js:3:17)
    at __require2 (chunk-62VDRKYJ.js?v=80dff520:19:50)
    at node_modules/minify-xml/index.js (index.js:244:17)
    at __require2 (chunk-62VDRKYJ.js?v=80dff520:19:50)
    at dep:minify-xml:1:16

This is because this package uses duplexify and pumpify packages, which require the Buffer class and the process object.
Is there a possibility for a browser-compatible version? My project has a lot of workers and to fix this issue I have to do weird things like this:

import { Buffer } from 'buffer';

(window as any).Buffer = Buffer;
(window as any).process = { version: 'browser' };

I'm aware there are other workarounds like polyfills, Vite plugins and other solutions, unfortunately they are not always fully reliable.

Please consider including browser-friendly export for this great library.

@kristian
Copy link
Owner

Mhm good idea, but definitely nothing "short term" on my agenda. If you want to suggest how to do this via a PR, please feel free. But atm. I don't think I will find the time to provide you a change that will suit your needs. This is mainly a NodeJS library and used e.g. in the Chromium project, so running in a browser, whilst I like the idea, is not a main priority for the library atm. Sorry.

I will flag this issue appropriately and if anyone wants to come up with a good suggestion in this direction, I will be happy to review / support.

@kristian kristian added enhancement New feature or request wontfix This will not be worked on labels Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants