Skip to content

Feature: Browser-compatible version #16

Description

@Techn1c4l

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions