Here you can see the options being created for use... https://github.com/o-network/http-store/blob/master/examples/fs-store.js#L184
And another example that just uses node's fs: https://github.com/o-network/http-store/blob/master/examples/fs-store-magic-extensions.js#L67
Update on circular dependencies - I tried some of the hacks from StackExchange here without success so far. I don't really understand how all this works well enough, so I might not be applying the right things in the right place but that's nothing new for me with nodejs!
I'm curious though that from the initial responses, people say
npm should take care of this. This makes me wonder if the issue is during development because I'm using
yarn link rdflib in safenetworkjs. Again I don't understand how node modules are processed well enough to think about this.
I may have to resort to something crude like inserting the functionality on a global object. I wanted to avoid that so that the only change needed to a Solid app would be to use a different solid-auth-client, and not change any of the code itself.
So I'm going back to thinking a Solid app would use a SAFE compatible solid-auth-client as follows:
In browser script:
window.safeJs = require(safenetworkjs).safeJs auth = require(solid-auth-client).auth
safeJs = require(safenetworkjs).safeJs auth = require(solid-auth-client).auth
or in html:
<script src='safenetworkjs.js'></src> <script src='solid-auth-client.bundle.js'></src>
noting also, imho, there are an array of complex issues that relate to such considerations whilst hoping the link with some of my thoughts is helpful
Follow up question (BTW I now have something building, not tested tho) regarding node modules...
If I'm bundling a module using webpack (solid-auth-client in this case), and it depends on another module (safenetworkjs) that supports both nodejs and webified operation, one way to handle this is with conditional requires. rdflib.js does this in fetcher.js for example.
That works, but in a dependent module you end up with a web build looking for modules that are not needed or available for web which leads to 'module not found' errors for things like 'fs' that are built ins for nodejs and so not installed in node_modules.
One way to solve this is to mark those 'missing' modules as 'externals' in the dependent module's webpack.config.js, but I would prefer it if I could do this without touching the dependent module, for example by avoiding conditional requires in the dependency module.
In safentworkjs I was doing this by having a different entry point
index-web.js which allows me to build a bundle that only has what it needs. However, when I build a module that depends on safenetworkjs, it picks up
index.js and if bundling for web, it will complain and I'll have to go and modify its webpack.config.js.
So TLDR; is there a way for a dependent module to be built for web (webpacked) in a way that picks up the web version of a dependency which has both web and nodejs builds. I wondered if putting the bundle in a './browser' directory was the answer, but it seems not.