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

Proposal: put a /browser and a /nodejs bundles at easy access #578

Closed
daviddias opened this issue Mar 5, 2020 · 6 comments
Closed

Proposal: put a /browser and a /nodejs bundles at easy access #578

daviddias opened this issue Mar 5, 2020 · 6 comments

Comments

@daviddias
Copy link
Member

Currently, getting a browser bundle and a node bundle takes a lot of extra steps. For beginners, it would be super good if they could just do:

require('libp2p/browser') and require('libp2p/nodejs') and get an all set libp2p bundle with the best configs™

@hugomrdias
Copy link
Member

IMO its better to do file swaps with package.json browser property as we have in ipfs, that way we can control over what gets executed.

Having different entry points as several down sides:

  • extra cognitive load
  • extra repo maintenance plus extra aegir support
  • electron would be a mess
    • user can have node integration on or off
    • user can be in the main thread (nodeish) or render thread (chromium) with node integration on or off
    • user can use a bundler or not (hard to choose here)
  • react-native would be extra messy
    • cause the env is kinda of an partially implemented hybrid between node and browser
    • we can use package.json react native property for swaps
  • we will end up in a situation where we would need to short circuit between browser and nodejs entries, making bundle size control really hard.

Having good config defaults plus some specific profile configs that we can controls with file swaps, would give a more easy and stable experience for our users.

@vasco-santos
Copy link
Member

FYI me and @jacobheun have been talking since the refactor about the need to improve config!

@jacobheun made an initial proposal on #576 and I feel that his proposal seems the way to go (did not read in deep yet, but from we discussed earlier, I think we are well aligned)

Currently, getting a browser bundle and a node bundle takes a lot of extra steps. For beginners, it would be super good if they could just do:

@daviddias FYI with the refactor we went away from the "bundle" naming as it was not being well interpreted by the community and we are having several issues on the naming. I wrote a libp2p/js-libp2p/CONFIGURATION.md and libp2p/js-libp2p/GETTING_STARTED.md that aim to help new users to go through the configuration. Even though this is a burden for users, and that's why we started discussing improving the configuration.

IMO its better to do file swaps with package.json browser property as we have in ipfs, that way we can control over what gets executed.

@hugomrdias js-libp2p acts as the composer for its compatible modules. Basically the modules are "plugged in" and js-libp2p makes them work together. The js-libp2p modules configuration is outside the scope of it, and this way it cannot be use the package.json browser property.

@hugomrdias
Copy link
Member

hugomrdias commented Mar 5, 2020

I don't really understand why we can't use file swap for a default config.
@jacobheun post seems to be inline with my thoughts here.

In the Example Configurations from jacob

you could expose a default config default.js that swaps between nodejs/browser, same for base.js, and still keep the specific files for advanced use cases (default-node.js, default-browser.js, etc)

This default.js could be the one used in a zero config instantiation.

Plus others profiles like the pubsub example.

@vasco-santos
Copy link
Member

@hugomrdias in that case it make sense yes! 👍

@daviddias
Copy link
Member Author

I'm fine with both. The goal is to give users a quick way to get started. @hugomrdias wanna take a stab at that PR following your pattern?

@vasco-santos
Copy link
Member

Closing as we will work on this in the context of #576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants