Skip to content

Open to use conditional exports instead of globalThis.Buffer? #87

@ukstv

Description

@ukstv

Hey, @achingbrain recently it was discovered that some crypto wallets forcefully polypill globalThis.Buffer with some garbage Buffer implementations. uint8arrays uses globalThis.Buffer quite extensively. I guess, the intent is to use native Node.js Buffer, not some polyfill. How do you think about moving Buffer-related code behind conditional exports?

Say, you could have #alloc which resolves to ./buffer-alloc.js when node-imported, and ./uint8array-alloc.js by default.

Also, node.js Buffer could be found in node:buffer on Bun and Node.js, which makes the code a bit simpler to read, and it definitely avoids implications of globalThis pollution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions