Fork me on GitHub
#shadow-cljs
<
2018-12-13
>
idiomancy00:12:35

Error handling response - class java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
<eval>:12
:(function (){var writer__7270__auto__ = (new java.io.StringWriter());
                                         ^

ReferenceError: java is not defined
    at <eval>:12:42
    at <eval>:16:3
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at runInThisContext (vm.js:139:38)
    at global.SHADOW_NODE_EVAL ([stdin]:75:30)
    at 
:thinking_face:

thheller00:12:27

@idiomancy that looks like it is trying to eval clojure code? that certainly is not valid CLJS 😉

idiomancy00:12:52

yeah, thats what I mean. This seems to be an error printing an exception. This is very strange.

idiomancy00:12:25

its an error with a websocket call

idiomancy00:12:45

being executed from js interop

idiomancy00:12:50

with no clojure involved

thheller00:12:56

what are you sending to the REPL?

thheller00:12:06

it looks to me like something is sent to the REPL to be eval'd

thheller00:12:23

hence the websocket in the stacktrace since that triggers the eval

idiomancy00:12:29

its an rpc call

idiomancy00:12:41

doing blockchain stuff

idiomancy00:12:00

thats interesting though

thheller00:12:19

it looks to me like you are sending maybe some CLJ macro code to the REPL

thheller00:12:29

ie. code that expands to CLJ not CLJS

Geoffrey Gaillard08:12:11

Hey guys! Just encountered something strange with :infer-externs :auto (shadow 2.7.9): Given this code:

(ns foo.bar)
(defprotocol JustUsedAsATag)
(defrecord SomeRecord [field]
    JustUsedAsATag)
I get this warning:
Cannot infer target type in expression (. (. SomeRecord -prototype) -foo$bar$JustUsedAsATag$)
It happens only when the protocol do not declare any method (empty protocol). Is this related to shadow? Should I open an issue?

thheller08:12:26

@ggaillard interesting. never seen that before. it did not happen previously?

Geoffrey Gaillard08:12:22

It's the first time I have a use case for an empty protocol, so I never tried before. Anyway I never saw this warning while compiling other libs thought

thheller08:12:07

but it did not happen with an empty protocol previously?

thheller08:12:43

I have an idea why it may be happening but confirmation would help

Geoffrey Gaillard08:12:53

Sorry I don't know since it's the first time I'm using an empty protocol.

metacritical12:12:42

Has anyone tried nw.js with shadow-cljs ?

thheller12:12:49

I'm using it with electron which is pretty much the same idea AFAICT?

metacritical13:12:04

@thheller Can you point me to a sample link on github?

thheller13:12:35

no idea about nw.js

metacritical13:12:01

I mean electron.

metacritical13:12:02

WoW this is what i wanted, thanks @thheller

aisamu13:12:58

Good morning! Is clj-refactor supported with the CIDER in shadow? Manually adding the dependencies don't seem to help. Here's what I currently have:

;; :dependencies 
                [com.billpiel/sayid "0.0.17"]
                [refactor-nrepl "2.4.0"]
                [cider/cider-nrepl "0.19.0-SNAPSHOT"]
;; Output after cider-connect
WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
CIDER is working fine, I'm just missing the refactoring features. (Haven't tried sayid, but I doubt it works on cljs)

thheller13:12:13

you need to add the middleware I guess

thheller13:12:29

:nrepl {:middleware [something.from.refactor-nrepl]}

aisamu18:12:34

Still get the "no project found" warning, but things are apparently working! Thanks!

pez14:12:35

@thheller: I still fail with building a working :release build. I get this stack trace (hopefully I haven't trunkated it too early again):

TypeError: Cannot read property 'core' of undefined
extensionHostProcess.js:344
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/cljs.core.js:8:280)
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/cljs.core.js:2044:3)
	at Module.t._initNodeRequire.r._compile (/Applications/Visual Studio )
	at Object.Module._extensions..js (module.js:653:10)
	at Module.load (module.js:561:32)
	at tryModuleLoad (module.js:504:12)
	at Function.Module._load (module.js:496:3)
	at Function.t._load (/Applications/Visual Studio )
	at Function.t.getExtensionPathIndex.then.s._load (/Applications/Visual Studio )
	at Function.t.getExtensionPathIndex.then.r._load (/Applications/Visual Studio )
	at Module.require (module.js:586:17)
	at n (/Applications/Visual Studio )
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/calva.fmt.formatter.js:1:232)
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/calva.fmt.formatter.js:37:3)
	at Module.t._initNodeRequire.r._compile (/Applications/Visual Studio )
At /lib/calva.fmt.formatter.js:1:232 it is requiring calva.js_utils.js which is built from this small cljs file:
(ns calva.js-utils)

(defn ^:export jsify [o]
  (clj->js o))

(defn ^:export cljify [o]
  (js->clj o :keywordize-keys true))

thheller14:12:31

what do the first few lines of /Users/petery/Projects/calva-lib/packages/lib/cljs.core.js look like?

pez14:12:47

First two:

var window=global;var $CLJS=require("./cljs_env");require("./goog.math.long.js");require("./goog.math.integer.js");require("./goog.string.string.js");require("./goog.object.object.js");require("./goog.array.array.js");require("./goog.uri.uri.js");require("./goog.string.stringbuffer.js");
var cljs$cst$keyword$ns,cljs$cst$symbol$root,cljs$cst$symbol$default_DASH_dispatch_DASH_val,cljs$cst$symbol$mseq,cljs$cst$symbol$defrecord_STAR_,cljs$cst$keyword$val,cljs$cst$symbol$_meta,cljs$cst$symbol$js_STAR_,cljs$cst$symbol$__hash,cljs$cst$symbol$ns_STAR_,cljs$cst$symbol$ascending_QMARK_,cljs$cst$symbol$fqn,cljs$cst$symbol$update_DASH_count,cljs$cst$symbol$off,cljs$cst$symbol$cnt,cljs$cst$keyword$status,cljs$cst$keyword$descendants,cljs$cst$symbol$nil_DASH_val,cljs$cst$symbol$dispatch_DASH_fn,

thheller14:12:39

looks like its supposed to

thheller14:12:58

can you gist the full file?

thheller14:12:40

not sure why this is happening but the code is in the wrong order

thheller14:12:46

may actually happen because of :simple. not actually sure though.

pez14:12:00

Let me try to remove that then…

thheller14:12:05

hmm yeah its probably because of :simple

thheller14:12:21

$CLJS.cljs = { tools: {} }; is declared too later

thheller14:12:28

or rather it is used before it is declared

pez14:12:10

Yeah, w/o :simple the build works.

pez14:12:06

I assume it does not really matter for my extension?

aisamu18:12:34

Still get the "no project found" warning, but things are apparently working! Thanks!

Whiskas18:12:44

How do i reference a javascript file from CLJS? i already inserted the folder in the source path

Whiskas18:12:13

@thheller, do you recommend using this when working with JSX or there is another way?

Whiskas18:12:19

i am already compiling the files with babel

thheller18:12:46

the babel example I linked the other day is pretty much what I recommend yes

Whiskas18:12:54

Do you know what is the main cause of this error? :

[:app] Build failure:
The required JS dependency "Components/list" is not available, it was required by "dbiz_health/common/views.cljs".

Searched in:/Users/pimentel/Projetos/dbiz-health/node_modules

You probably need to run:
  npm install Components/list

Whiskas18:12:22

it is looking for it in node_modules

Whiskas18:12:40

:source-paths
 ["src/cljs"
  "src/clj"
  "src/gen"
  "test/cljs"
  "test/clj"]

thheller18:12:49

because you didn't read the docs

Whiskas18:12:26

when i read them i got the belief that putting the folder in sources was enough, i think i did not read it more carefully

thheller18:12:33

you need the / in front otherwise it'll check node_modules as thats the notation for npm

Whiskas18:12:17

it worked, thanks

Whiskas19:12:46

I’m seeing that this example is kinda different from the javascript i generated locally

Whiskas19:12:50

import React from "react"


const MyComponent = ({ key }) => {
  console.log('child props: ', key)
  return (
    <li key={key}>
      Hello JSX!
    </li>
  )
}

const MyDefaultComponent = ({ children }) =>
  <div>
    <h1>Hello JSX!</h1>
    <ul>
      {children}
    </ul>
  </div>


export { MyComponent }

export default MyDefaultComponent

Whiskas19:12:12

I’m having a null reference error in “React”

Whiskas19:12:38

My generated file is importing React with the ES6 syntax import React from "react"

Whiskas19:12:50

and the one from the example is doing it in another way

Whiskas19:12:38

Should i try to generate .js files like that or the cause for this error is other?

Whiskas19:12:03

Error:

MyComponent.js:7 Uncaught TypeError: Cannot read property 'createElement' of undefined
    at MyComponent (MyComponent.js:7)
    at beginWork (react-dom.development.js:14564)
    at performUnitOfWork (react-dom.development.js:17821)
    at workLoop (react-dom.development.js:17861)
    at HTMLUnknownElement.callCallback (react-dom.development.js:150)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
    at invokeGuardedCallback (react-dom.development.js:257)
    at replayUnitOfWork (react-dom.development.js:17108)
    at renderRoot (react-dom.development.js:17980)
    at performWorkOnRoot (react-dom.development.js:18838)

thheller19:12:33

you must generate ES6 modules. don't let babel turn import into require

thheller19:12:29

also you pasted the same code twice? where is yours?

Whiskas19:12:03

ops, i think i edited the wrong post,

Whiskas19:12:06

i will edit it again

Whiskas19:12:49

So, i did a test here

Whiskas19:12:55

and with es2015 it works fine

Whiskas19:12:07

i just need to learn how to make it to work with es2016

Whiskas19:12:20

i will post the generated es2016

Whiskas19:12:52

generated es2016:

import React from "react";

var MyComponent = function MyComponent(_ref) {
  var key = _ref.key;

  console.log('child props: ', key);
  return React.createElement(
    "li",
    { key: key },
    "Hello JSX!"
  );
};

var MyDefaultComponent = function MyDefaultComponent(_ref2) {
  var children = _ref2.children;
  return React.createElement(
    "div",
    null,
    React.createElement(
      "h1",
      null,
      "Hello JSX!"
    ),
    React.createElement(
      "ul",
      null,
      children
    )
  );
};

export { MyComponent };

export default MyDefaultComponent;
`

Whiskas19:12:36

the null reference error is coming from React when trying to call .createElement

thheller19:12:14

hmm es6 is supposed to work but maybe the import stuff for npm is broken there

thheller19:12:17

haven't used that in a while

thheller19:12:34

stick with es2015 for now. don't have time to look into it right now.

Whiskas19:12:05

the difference between using e2016 and 2015 is that es2015 does’nt get google closure’s advanced optimization, right?

thheller19:12:39

that is correct yes