fiatjaf / tiddlywiki-remotestorage

a syncadaptor plugin that saves tiddlers on custom remoteStorage directories
https://tiddly.fiatjaf.com/
21 stars 4 forks source link

Unable to build the plugin #6

Open bourgeoa opened 5 years ago

bourgeoa commented 5 years ago

I wanted to build your plugin and followed all steps in https://tiddlywiki.com/dev/ It does compile but when I use the index.html I got :

Internal JavaScript Error
Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser
uncaught exception: Cannot find module named 'remotestoragejs' required by module '$:/plugins/tiddlywiki/remotestorage/syncadaptor.js', resolved to remotestoragejs

It seems that const remostorage = require("remotstoragejs") was not resolved.

Can you tell me how you did it. I'm using node.js 8.9.4

I'm using your plugin as an example to develop a syncadaptor to node-solid-server.

fiatjaf commented 5 years ago

I don't remember exactly what I did, I just remember having a lot of trouble.

Basically, if you were to build this plugin, you would have to

  1. Clone https://github.com/Jermolene/TiddlyWiki5
  2. Clone tiddlywiki-remotestorage to a folder inside the folder plugins/tiddlywiki
  3. Build it with npm install and npm build
  4. Add the plugin to one of the "editions" definition (or create your own edition)
  5. Run one of the CLI commands to build the TiddlyWiki edition, it's something like ./tiddlywiki.js editions/whatever --build index (tiddlywiki.js is in the root)

That will give you an HTML file that is a full TiddlyWiki instance with your plugin available.

Please let me know if I can help you with anything else. I'm also on #tiddlywiki on Freenode.

fiatjaf commented 5 years ago

Considering the error you're seeing, it's because you didn't build the plugin with npm. But that is out of the scope of TiddlyWiki, it's just the basic thing all JavaScript people do: they use modules from npm as if they were writing Node.js code, then run browserify or something else on them to get a single JavaScript file with all files and dependencies bundled together, then they include that on the HTML.

You don't necessarily need to do that (specially if you're not using any external dependency), but if you want to, take a look at Browserify.

Also, you won't need the remotestorage package.

bourgeoa commented 5 years ago

Thank you very much. Your 2 mails where a very good explanation.

As a result I take a quick course on nmp. And looked at the intent of browserify.

I don't know where readonly is set and I do not understand your code related to readonly case in getclient().

All the best for Xmas and New Year

fiatjaf commented 5 years ago

readonly is just a variable specific to this plugin. I set it at the following lines: https://github.com/fiatjaf/tiddlywiki-remotestorage/blob/4e3af0636689b60e8a6e93462d8bd1512f0f83e2/main.js#L19-L21. It's relevant just because you could be browsing a remoteStorage instance that is not yours, thus it will be readonly.

getClient is also just a helper function for building the RemoteStorage client. Again, shouldn't be relevant to your implementation.