This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-12
Channels
- # aleph (1)
- # announcements (1)
- # beginners (54)
- # calva (11)
- # clojure (55)
- # clojure-france (1)
- # clojure-italy (4)
- # clojure-spec (10)
- # clojure-uk (7)
- # clojurescript (3)
- # cursive (3)
- # data-science (8)
- # datomic (10)
- # emacs (1)
- # fulcro (21)
- # graalvm (2)
- # jobs (1)
- # kaocha (1)
- # nrepl (1)
- # nyc (1)
- # other-languages (5)
- # reitit (8)
- # rum (5)
- # shadow-cljs (84)
- # spacemacs (2)
- # sql (20)
- # testing (3)
- # vim (1)
@thheller wow thats a great help Thomas ! i was playing with macros a time ago
BTW do you have an idea why i cannot compile this macro with clojurescript?
(defmacro str->int [s]
`(js/parseInt s))
@papachan define "cannot compile". When I read "cannot compile" I try this and it compiles just fine
$ clj
Clojure 1.10.1
(defmacro str->int [s]
`(js/parseInt s))
#'user/str->int
so the macro is technically fine. just something in your use isn't. also why is this a macro and not a regular defn? no point in making this a macro?
18 | (js/console.log (str->int "1"))
-------------------------^------------------------------------------------------
Use of undeclared Var server.macros/s
BUILD-WARNING in server/main.cljs at [18:19]
Use of undeclared Var server.macros/s
otherwise the macro expands to (js/parseInt server.macros/s)
since it is just expanding the regular s
symbol
I try to run shadow with an npm package
Namely zenroom
But when I add it and import it in the require
package.json
:
{
"name": "zenroom-example",
"version": "0.0.1",
"private": true,
"devDependencies": {
"shadow-cljs": "2.8.64"
},
"dependencies": {
"core-js": "^3.2.1",
"core-util-is": "^1.0.2",
"create-react-class": "15.6.3",
"react": "16.8.6",
"react-dom": "16.8.6",
"regenerator-runtime": "^0.13.3",
"zenroom": "0.9.5"
}
}
I get the message:
The required JS dependency "core-util-is" is not available, it was required by "node_modules/readable-stream/lib/_stream_readable.js".
Note: this only happens when I change a file and shadow-cljs pushes changes to the browser.
When doing npm i core-util-is
or npm i --save core-util-is
the error remains
Only way to avoid it is by removing the [zenroom]
import in the view
(ns zenroom-example.views
(:require
[re-frame.core :as re-frame]
[zenroom]
[zenroom-example.subs :as subs]))
Any solution for this?
From the documentation this should be the way to do an npm import
Via lein dev
I see this:
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".
You probably need to run:
npm install readable-stream/writable.js
npm install readable-stream/writable.js
npm ERR! Error while executing:
npm ERR! /usr/local/bin/git ls-remote -h -t
npm ERR!
npm ERR! ERROR: Repository not found.
Code in readable-stream/writeable.js
module.exports = Stream;
var EE = require('events').EventEmitter;
var inherits = require('inherits');
inherits(Stream, EE);
Stream.Readable = require('readable-stream/readable.js');
Not the first one: https://clojurians-log.clojureverse.org/shadow-cljs/2018-08-17
Try removing node_modules and package.json apparently
Still same
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".
@erwinrooijakkers I don't know what zenroom is but it looks like it just isn't supposed to run in the browser?
it also seems dead with 12 weekly downloads? https://www.npmjs.com/package/zenroom
and there is a deprecated message on the repo https://github.com/DECODEproject/zenroomjs (and it is archived)
Aha thanks! ๐
It does work in the browser there are examples on https://dev.zenroom.org/demo/
Itโs not dead, itโs just born. The npm package is indeed refering to deprecated repo
It does use wasm yes
I do see an error exception: abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info.
when running
Anyway I get an object thatโs accessible now in the browser, Iโll try to use that
Thanks for the feedback! I appreciate it
Hmm errors like failed to load shadow.module.app.append.js TypeError: "module$node_modules$zenroom$index.script is not a function"
. So this approach is not the right one. I wonder how to run it in a browser at all ๐
Ah this helped:
(:require [zenroom :default zenroom])
Now (js/Object.getOwnPropertyNames zenroom)
lists all its properties
scriptkeysconfdataprintsuccessverbosityzenroom_execzencode_execerrorinitreset__debug
So something is working
But the wasm error uncaught exception: abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info.
might be due to limitations of shadow-cljs?
@erwinrooijakkers wasm is not supported, so you are not going to get this running with shadow-cljs
I see. I also see the shadow-cljs issue related to wasm: https://github.com/thheller/shadow-cljs/issues/397. What makes it difficult to use wasm from shadow-cljs? I mean the npm package uses it, not shadow-cljs itself?
shadow-cljs bundles the npm package. it doesn't know how to bundle .wasm. if you load wasm manually it all works completely fine, there just is no "standard" for packaging .wasm yet and I haven't had the time to implement it the way webpack did
Ah okay so I can include the wasm file
And for including an npm package in a plain javascript project it does work?
Okay ๐
I look up information on how wasm is bundled in npm
but the file somehow needs to get out of node_modules/whatever/foo.wasm
to your public/wasm/foo.wasm
or so
Ah exactly
And that is not a standard location?
Ah I see
Thanks this clears things up!