Irys-xyz / arweave-js-sdk

JS SDK for Irys on Arweave
110 stars 95 forks source link

Arbundles causing `window is not defined` #64

Closed callensm closed 1 year ago

callensm commented 1 year ago

When trying to deploy to a Cloudflare worker, I get the error:

Uncaught ReferenceError: window is not defined
    at index.js:16761:5 in ../../node_modules/arweave/web/index.js
    at index.js:18:51 in __require2
    at index.js:16809:38 in ../../node_modules/arbundles/src/deepHash.js
    at index.js:18:51 in __require2
    at index.js:16909:22 in ../../node_modules/arbundles/src/ar-data-base.js
    at index.js:18:51 in __require2
    at index.js:87941:26 in ../../node_modules/arbundles/src/ar-data-bundle.js
    at index.js:18:51 in __require2
    at index.js:88456:28 in ../../node_modules/arbundles/src/index.js
    at index.js:18:51 in __require2
   [code: 10021]

This is using the Bundlr (default) client, but looks like the arbundles dependency is still using some web-based build and causing an issue.

callensm commented 1 year ago

looks like it could be related to this import https://github.com/Bundlr-Network/arbundles/blob/master/src/deepHash.ts#L3.

might need environment checking to conditionally import from arweave/node when not in browser

JesseTheRobot commented 1 year ago

I've created an issue for CF's workers to allow for resolving entrypoints from main (instead of just browser) - but until that is done, node-window-polyfill will have to suffice.