reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
xhh 2020-03-06T03:14:48.113500Z

😆 Thanks for sharing your experiences.

juhoteperi 2020-03-06T12:15:11.114100Z

Surprise Reagent release (no huge new features, yet): https://github.com/reagent-project/reagent/blob/master/CHANGELOG.md#0100-2020-03-06 !

6👏
frozar 2020-03-06T14:20:01.115200Z

Hi, I use shadow-cljs and I'm experiencing some issue regarding the import of the roughjs npm package. The installation of the package have been done by npm command npm i roughjs. In the application code, I have:

(ns <http://my.app|my.app>
  (:require ["roughjs" :default rough]
            )
  )
[...]
When I try to compile this shadow-cljs compile app, I get the following error messages:
[:app] Compiling ...
Closure compilation failed with 9 errors
--- node_modules/roughjs/bundled/rough.js:2
Class names defined inside a function cannot be reassigned.
--- node_modules/roughjs/bundled/rough.js:2
Class names defined inside a function cannot be reassigned.
--- node_modules/roughjs/bundled/rough.js:2
Class names defined inside a function cannot be reassigned.
--- node_modules/roughjs/bundled/rough.js:2
Class names defined inside a function cannot be reassigned.
--- node_modules/roughjs/bundled/rough.js:2
Class names defined inside a function cannot be reassigned.
--- remaining errors ommitted ...
As the bundled/rough.js is a uglyfied code, it's really hard to investigate. Does anyone have a hint on how I can import correctly this package please?

thheller 2020-03-06T14:58:14.116300Z

@fabien.rozar try ["roughjs/bundled/rough.esm.js" :default rough]. dunno why it doesn't like the default bundle

frozar 2020-03-06T15:31:09.117600Z

Great, that works! I don't why the default bundle is not accepted, but happy the application is working 😸

frozar 2020-03-06T15:41:29.119800Z

Actually, I'm trying to put in place some test in the project. My test file is as simple as that:

(ns rough.app-test
  (:require [<http://rough.app|rough.app> :as app]
            [cljs.test :refer (deftest is)]))

(deftest a-failing-test
  (is (= 1 2)))
When I try the command shadow-cljs compile test, I get an error regarding the import (again) or js syntax issue:
[:test] Compiling ...
========= Running Tests =======================
SHADOW import error /home/frozar/wk/cljs_roughjs/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$roughjs$bundled$rough_esm.js
/home/frozar/wk/cljs_roughjs/node_modules/roughjs/bundled/rough.esm.js:1
const t="<http://www.w3.org/2000/svg>";function e(t,e,s){if(t&amp;&amp;t.length){const[n,i]=e,a=Math.PI/180*s,o=Math.cos(a),h=Math.sin(a);t.forEach(t=&gt;{const[e,s]=t;t[0]=(e-n)*o-(s-i)*h+n,t[1]=(e-n)*h+(s-i)*o+i})}}function s(t){const e=t[0],s=t[1];return Math.sqrt(Math.pow(e[0]-s[0],2)+Math.pow(e[1]-s[1],2))}function n(t,e){return t.type===e}const i={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:4,t:2,V:1,v:1,Z:0,z:0};class a{constructor(t){this.COMMAND=0,this.NUMBER=1,this.EOD=2,this.segments=[],this.parseData(t),this.processPoints()}tokenize(t){const e=new Array;for(;""!==t;)if(t.match(/^([ \t\r\n,]+)/))t=t.substr(RegExp.$1.length);else if(t.match(/^([aAcChHlLmMqQsStTvVzZ])/))e[e.length]={type:this.COMMAND,text:RegExp.$1},t=t.substr(RegExp.$1.length);else{if(!t.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];e[e.length]={type:this.NUMBER,text:`${parseFloat(RegExp.$1)}`},t=t.substr(RegExp.$1.length)}ret

SyntaxError: Unexpected token 'export'
    at wrapSafe (internal/modules/cjs/loader.js:1067:16)
    at Module._compile (internal/modules/cjs/loader.js:1115:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /home/frozar/wk/cljs_roughjs/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$roughjs$bundled$rough_esm.js:3:51
    at global.SHADOW_IMPORT (/home/frozar/wk/cljs_roughjs/out/node-tests.js:64:44)
    at /home/frozar/wk/cljs_roughjs/out/node-tests.js:2258:1
===============================================

thheller 2020-03-06T15:42:23.120900Z

well node doens't support ESM ...

frozar 2020-03-06T15:43:12.121600Z

Ooooh, OK. Do I have a way to test my namespace which use ESM module?

2020-03-06T18:00:46.122Z

@manutter51 thanks for the tip - I overlooked it yesterday - I’ll experiment with this

1👍