Fork me on GitHub
#shadow-cljs
<
2020-04-18
>
David Pham08:04:06

Did you try the config merge flag?

emil0r09:04:34

I can make that work

Eamonn Sullivan10:04:49

Hi all, I have a small experimental Clojure library (https://github.com/eamonnsullivan/github-search) that I'd like to turn into a mono-repo that produces both a jar and an npm package (shadow-cljs), with some common code (.cljc). Is this possible? Has anyone tried this and can point me to an example I can study?

thheller10:04:24

by npm package you mean code meant to be consumed from JS?

Eamonn Sullivan11:04:49

Code consumed by JS, installable via npm or yarn.

thheller10:04:33

or just used as a regular CLJS lib?

Andrea Russo11:04:14

Hello everyone

Andrea Russo11:04:02

I have a re-frame project where I need to have some react components written in React JSX.

Andrea Russo11:04:18

I’m trying to build my project following the shadow-cljs guide about importing and cosuming javascript modules and everything compiles correctly, but when I’m using my js component in my cljs code, i get the following error:

Andrea Russo11:04:32

TypeError: Cannot read property ‘createElement’ of undefined

Andrea Russo11:04:52

the babel generated code for the component is this:

Andrea Russo11:04:09

import React from ‘react’; function myComponent() { return /#PURE__/React.createElement(“h1”, null, “JSX!“); } export { myComponent };

Andrea Russo11:04:48

and the generated code looks like this:

Andrea Russo11:04:56

var module$node_modules$react$index = shadow.js.require(“module$node_modules$react$index”, {}); function myComponent$$module$myComponent() { return module$node_modules$react$index.default.createElement(“h1", null, “JSX!“); }

Andrea Russo11:04:35

it seems that that extra default property in the return statement leads to the error

Andrea Russo11:04:50

module$node_modules$react$index in the browser js runtime exists and has a createElement attribute

Andrea Russo11:04:25

I’m using shadow-cljs version 2.8.97

Andrea Russo11:04:19

I’m really stuck

thheller11:04:58

import React from ‘react’; this is the issue, should be import * as React from "react";

thheller11:04:23

otherwise it accesses the .default property which react doesn't have

Andrea Russo14:04:26

thank you very much for the hint

thheller15:04:29

well technically your way is correct but commonjs<->esm interop is weird at the moment

Andrea Russo15:04:55

it works perfectly with your suggested change

Andrea Russo15:04:14

and thank you very much also for shadow-cljs

Andrea Russo15:04:20

e fantastic tool!

Andrea Russo15:04:27

a fantastic tool!

👍 4
mauricio.szabo15:04:08

By the way, recently I was having trouble using shadow-cljs with an electron project. I was getting an error: failed to parse websocket message... when whatching my project and running electron. I was just abouit to open an issue right now, and it's already fixed! Thanks a lot 😄

mauricio.szabo18:04:08

For some reason, since the version, version 2.8.90 I was having some problems with different targets like electron, with a message

failed to parse websocket message {:type :repl/init, :repl-state {...lots of things here...

thheller20:04:31

fixed in 2.8.98. some REPL files weren't actually written to disk unless they were used in the regular build

Donal Mac An Ri23:04:28

Hello all, wondering if anyone here has had any success working with shadow-cljs in WSL2 on windows? I'm getting this error any time I try to start either the browser or node-repl:

[:browser-repl] Build completed. (130 files, 0 compiled, 0 warnings, 2.55s)
null=> Execution error (AssertionError) at shadow.cljs.repl/read-one (repl.clj:535).
Assert failed: (symbol? read-ns)