MainframeOS / erebos

JavaScript client and CLI for Swarm
https://erebos.js.org
MIT License
47 stars 12 forks source link

How should local development work #94

Closed vmaark closed 5 years ago

vmaark commented 5 years ago

Description

I'm developing an application where I'd like to use erebos. There are some issues which I'd like to solve in the library, so I check out the repo to make changes to it. I place a symlink in my project's node_modules folder which points to the specific erebos package (api-bzz-browser) I need.

Disclosure: this is a react-native package which uses the metro bundler and it has an open issue about not being able to handle symlinks https://github.com/facebook/metro/issues/1. I'm using a workaround where I specifically tell it where to look for source files, which solves this issue.

Issues

I'm still new to Lerna, and not sure what else influences the build, but it would be nice to have documentation regarding how to set up local development of erebos as a dependency. It's also possible that these issues only arise when it's being consumed by react-native / metro bundler.

PaulLeCam commented 5 years ago

The rxjs dependency missing in @erebos/api-bzz-base is a mistake, I fixed it in v0.8.1, thanks for reporting it. Regarding hoisting of dependencies yes it's the expected behavior with Yarn workspaces and Lerna.

vmaark commented 5 years ago

So what should be the suggested way of setting up local an erebos package as a local dependency? Because of the hoisting by yarn workspaces, the modules are not found.

PaulLeCam commented 5 years ago

Hoisting relies on node's module resolution algorithm so I think the issue you're having might be caused by metro's behavior being different. I've used linked Erebos packages in other local node projects without any issue so unless there is something wrong with the current setup you could point me at, I don't know what we can be done on this end.

vmaark commented 5 years ago

This is indeed an issue caused by metro, but I don't see a simple workaround on the consumer side. I'm trying out different things in the erebos project at the moment, is there some way of setting up yarn to install the dependencies to the respective subpackages' node_modules folder?

PaulLeCam commented 5 years ago

Yarn supports a "nohoist" config so that might be an option but I don't know enough about the React Native/metro constraints to know if that would work in your case.

vmaark commented 5 years ago

(related to #52) Thanks, I managed to make it work based on that article. In the root package.json I had to add to workspaces the nohoist config, disabling it for all modules:

"workspaces": {
  "packages": [ "packages/*" ],
  "nohoist": [ "**/**" ]
}

There is one more manual step though: copying the the erebos dependencies of api-bzz-browser to node_modules/@erebos/.

This is not ideal, but there seems to be activity regarding fixing symlinks in react-native land: https://github.com/facebook/metro/pull/257, https://github.com/facebook/jest/pull/7549 If these got merged, up-to-date react-native projects should not need the copying part at least.