Fork me on GitHub
#shadow-cljs
<
2020-04-18
>
neo255108: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!

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.macanri23: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)