Skip to content

Replacing global (node only) with globalThis (cross-platform) #22

Closed

Description

@tharvik

There is a new way to access globally defined variable, which is the same for both node and browsers, see Firefox' JS reference.

Currently, it's using global directly, which is only defined on node.
https://github.com/crypto-browserify/randombytes/blob/f18ded32b209f0d4c637608a11ae042ae96b4c2e/browser.js#L16

btw, why did you not use windows directly as it is meant for browser?

Activity

  1. calvinmetcalf commented on Sep 8, 2020

    @calvinmetcalf
    Contributor

    @jimmywarting yes you are correct on the reasons, this is meant to be used with browserify or webpack which auto handle subbing those things in

  2. matthewdavi commented on Apr 15, 2021

    @matthewdavi

    This would be a big help. I am using this tool with Vite and it currently throws an error due to using global instead of globalThis.

  3. calvinmetcalf commented on Apr 15, 2021

    @calvinmetcalf
    Contributor

    yeah I don't thing globalThis has enough support to be used exclusively yet https://github.com/rollup/plugins/tree/master/packages/inject might help you out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions