browserify / randombytes

random bytes from browserify stand alone
MIT License
99 stars 47 forks source link

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

Closed tharvik closed 1 year ago

tharvik commented 4 years ago

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?

calvinmetcalf commented 4 years ago

@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

matthewdavi commented 3 years ago

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.

calvinmetcalf commented 3 years ago

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