Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser support? #3

Open
mattlenz opened this issue Mar 19, 2018 · 8 comments

Comments

@mattlenz
Copy link

@mattlenz mattlenz commented Mar 19, 2018

Compiling into an app with webpack, I get the following

module not found:

- dgram: imported at node_modules/dns-socket/index.js
- dns: imported at node_modules/k-rpc-socket/index.js
- net: imported at node_modules/discovery-swarm/index.js

Is browser support planned for Hypermerge -- or maybe I have missed some configuration?

AFAIK hypercore can work in the browser.

@jimpick

This comment has been minimized.

Copy link
Contributor

@jimpick jimpick commented Mar 20, 2018

I recently dealt with the same problem. You can modify your webpack configuration like this:

  // Some libraries import Node modules but don't use them in the browser.
  // Tell Webpack to provide empty mocks for them so importing them works.
  node: {
    dgram: 'empty',
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
    child_process: 'empty',
    dns: 'empty'
  },

Here is the webpack documentation:

https://webpack.js.org/configuration/node/

@mattlenz

This comment has been minimized.

Copy link
Author

@mattlenz mattlenz commented Apr 4, 2018

Thanks @jimpick -- compiles now but with a warning that one require statement is the result of an expression.

Now the next trick will be a replacement for discovery-swarm that will work in browser. May be possible with a https://github.com/mafintosh/signalhub and https://github.com/mafintosh/webrtc-swarm

@millette

This comment has been minimized.

Copy link

@millette millette commented Jun 27, 2018

@mattlenz

This comment has been minimized.

Copy link
Author

@mattlenz mattlenz commented Jun 29, 2018

Thanks @millette -- fixed those links!

@jackmac92

This comment has been minimized.

Copy link

@jackmac92 jackmac92 commented Sep 15, 2019

Any update on this? Really interested in running this in the browser

@pvh

This comment has been minimized.

Copy link
Contributor

@pvh pvh commented Sep 16, 2019

Hi! I don't think anyone is working on this at the moment, but I'm curious why you'd want this? If your users are downloading your application in a browser, by definition they're accessing a server. If they're communicating via WebRTC, they can both reach a signalling server to communicate.

A much, much, much simpler solution (for the browser) if you already have users who are online and able to reach the same server is just to write a very simple websocket echo server. It only takes a few dozen lines of code to implement something passable and reasonably scalable for small application and it has all the same availability characteristics.

I might work on this at some point because I already have a local-first application I want to add cloud-support to so that I can share content with people who haven't installed the tool, so it's not like I think it's useless or anything, I just am genuinely interested in better understanding why this has come up a few times.

@falafeljan

This comment has been minimized.

Copy link

@falafeljan falafeljan commented Oct 21, 2019

Well, the web is still the de-facto way of distribution for many applications (besides apps that are native or built with Electron or react-native). With the reliance on SQLite in the current state of hypermerge we're somewhat limited, but generally speaking, there are ways to realize at least the serverless-ish network within the browser with hyperswarm-proxy: https://github.com/RangerMauve/hyperswarm-proxy

What I'm currently attempting is an architecture where feed replications are happening 'natively' in local applications, but integration with web-based apps happens via Hyperswarm/WebRTC and W3C standards (usig HTTP, but within a decentralized swarm). The idea is to decouple the API from Hypermerge's replication mechanism, and create an SDK that works in most modern browsers.

Maybe that's of use for some folks.

@pvh

This comment has been minimized.

Copy link
Contributor

@pvh pvh commented Oct 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.