RangerMauve / hyper-sdk

Make your own hyper apps!
https://www.youtube.com/watch?v=HyHk4aImd_I&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=20
MIT License
291 stars 46 forks source link

Building a bundle for Browsers fails #72

Closed paul90 closed 3 years ago

paul90 commented 3 years ago

Looks to be cause by a problem reported upstream as https://github.com/sodium-friends/sodium-universal/issues/6

npm run build fails with:

❯ npm run build

> hyper-sdk@3.0.2 build /Users/Paul/Projects/hyper/sdk
> cross-env BABEL_DISABLE_CACHE=1 browserify -t [ babelify --global ] --standalone hyperSDK index.js > hyper-sdk-bundle.js

Error: Can't walk dependency graph: Cannot find module './crypto_auth' from '/Users/Paul/Projects/hyper/sdk/node_modules/sodium-universal/index.js'
    required by /Users/Paul/Projects/hyper/sdk/node_modules/sodium-universal/index.js
    at /Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:137:35
    at load (/Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:156:43)
    at onex (/Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:181:17)
    at /Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:15:69
    at FSReqCallback.oncomplete (fs.js:183:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hyper-sdk@3.0.2 build: `cross-env BABEL_DISABLE_CACHE=1 browserify -t [ babelify --global ] --standalone hyperSDK index.js > hyper-sdk-bundle.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hyper-sdk@3.0.2 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Paul/.npm/_logs/2020-12-15T10_44_05_883Z-debug.log

Oh, and there is a missing npm install between cd sdk and npm run build in the readme.

RangerMauve commented 3 years ago

Thank you for looking into this, I haven't tested browser builds in a while.

Does pinning the version to 3.0.2 in the SDK's package.json help?

paul90 commented 3 years ago

Not sure, the browser build process works, but two of tests (51 and 52) fail with Firefox 83.0 (they all pass in Firefox 85.0b1 and Chrome).

Console Log: Click to expand ``` 07:07:32.908 not ok 51 no error reading from core default_stream.js:25:26 07:07:32.908 --- default_stream.js:25:26 07:07:32.908 operator: error default_stream.js:25:26 07:07:32.908 expected: |- default_stream.js:25:26 07:07:32.908 undefined default_stream.js:25:26 07:07:32.908 actual: |- default_stream.js:25:26 07:07:32.908 { [Error: Block not available from peers] code: '', errno: 0, details: '' } default_stream.js:25:26 07:07:32.908 stack: |- default_stream.js:25:26 07:07:32.908 decode@http://localtest.me:3000/test-bundle.js:2619:17 default_stream.js:25:26 07:07:32.908 _onmessage@http://localtest.me:3000/test-bundle.js:8948:35 default_stream.js:25:26 07:07:32.908 _nextState@http://localtest.me:3000/test-bundle.js:9247:14 default_stream.js:25:26 07:07:32.908 _readMessage@http://localtest.me:3000/test-bundle.js:9166:19 default_stream.js:25:26 07:07:32.908 recv@http://localtest.me:3000/test-bundle.js:9145:44 default_stream.js:25:26 07:07:32.908 _write@http://localtest.me:3000/test-bundle.js:9011:22 default_stream.js:25:26 07:07:32.908 update@http://localtest.me:3000/test-bundle.js:93416:14 default_stream.js:25:26 07:07:32.908 updateWriteNT@http://localtest.me:3000/test-bundle.js:93745:6 default_stream.js:25:26 07:07:32.908 [435]

Also at the end of the console log there are 6 Uncaught (in promise) NRPC_ERR_CLOSE: nanomessage-rpc was closed errors.

paul90 commented 3 years ago

While typing my reply, above, I noticed that there was an incoming update to Firefox - retesting with this updated version Firefox 84.0 the tests all pass. So it looks as if pinning sodium-universal to 3.0.2 helps.

Not looked into all the changes that Firefox 84.0 brings. But, I do know that it corrects a long standing issue with the handling of localhost, adding support for localhost subdomains.

RangerMauve commented 3 years ago

Sweet, thank you for looking into this.

Would you be down to submit a pull request for pinning the version?

paul90 commented 3 years ago

Should be able to put together a PR.

paul90 commented 3 years ago

Think I've found the underlying problem. The problem is with the sodium-universal 3.0.3 package not containing everything it should. It looks very much as if the prepublish didn't run!

If I clone the sodium-universal repo alongside the sdk repo, run npm i and then the run the prepublish script, then over in the sdk directory install sodium-universal from the local repo, using npm i $(npm pack ../sodium-universal | tail -1) the build for the browser works.

I'm going to close the PR.

paul90 commented 3 years ago

Closing this. The release of sodium-universal@3.0.4 has fixed this issue.