Hello,
I want to write a simple proof-of-concept (which may eventually evolve into something more serious) GUI wallet for a cryptocurrency that I’ve been writing. As desktop libraries/languages are either not very functional or not very portable, ClojureScript plus local storage in browser as a database looks like a good choice. To make it work, I need support for Ed25519 (a public-key signature system).
Fortunately, there are implementations of Ed25519 compiled to JavaScript. js-nacl is a “pure-Javascript High-level API to Emscripten-compiled libsodium routines”, available also as a NPM package, and post at
https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules advertises “Seamless interaction with NPM dependencies”. I tried to use it, roughly in the following way:
⒈ lein new reagent-frontend ercoin-wallet
⒉ Added :npm-deps {:js-nacl "1.2.2"} to :cljsbuild ⇨ :builds ⇨ app ⇨ :compiler in project.clj.
⒊ Added [js-nacl :as nacl] to :require in core.cljs
However :npm-deps seemed to be ignored. Fixed this by downgrading ClojureScript from 1.9.908 to 1.9.671 (BTW, these versions are not tagged in the Git repository), but then there are warnings:
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module […] at […]
, where modules are “fs”, “path” and “crypto”.
spinningtopsofdo on IRC said that “From a quick skim for js-nacl it looks like it's using emscripten and doing some unique module loading that Google Closure isn't aware of (
https://github.com/tonyg/js-nacl/blob/master/lib/nacl_factory.js#L30-L39).” and “I think it's more the way js-nacl is using ASM / Emscripten and creating JavaScript Modules. :npm-deps covers the common JavaScript module patterns (e.g. CommonJs, Node, UMD) but there is still many edge cases out there”.
I’ve tried also tweetnacl-js, but similarly there is a warning:
“WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "crypto" at […]”.
What is the status of NPM interoperability then? Is it supposed to work as plug & play or does it require hacky knowledge in some cases?