Fork me on GitHub
#shadow-cljs
<
2018-03-30
>
claudiu06:03:54

Hi, Noob question. I'm using Cursive and fallowing the instructions in the fulcro-lein-template. Build works, hot reload works, repl seems to work for stuff like "(+ 1 2)" but not (js/console.log "test") -> No such namespace: js,. Am I doing something wrong or is this the way it's supposed to work ?

danielo51515:03:58

Is any way to start a watch and a repl on a single operation ?

danielo51518:03:06

I just want to report that :reload still not work

thheller18:03:45

@rdanielo how does :reload not work? I tested it yesterday?

danielo51519:03:19

But those methods are for spawning an standalone repl, I want to launch a watch and a repl attached to it.

danielo51519:03:10

Well, it may be something related to my setup

danielo51519:03:14

Or how do I use it

danielo51519:03:45

Can you describe the correct steps to reload a file and then execute the functions within it ?

danielo51519:03:00

I am really missing the haskell :load functionality

thheller19:03:16

don't know haskell

thheller19:03:19

in the REPL

thheller19:03:48

(require '[the.thing :as x]) then (x/foo)

thheller19:03:54

to reload (require 'the.thing :reload)

đź‘Ť 4
mynomoto19:03:17

@thheller do you know if this is a bug or if I'm doing something wrong?

The required namespace "mranderson047.reagent.v0v8v0_alpha2.reagent.core" is not available, it was required by "day8/re_frame_10x/view/event.cljs".
"mranderson047/reagent/v0v8v0_alpha2/reagent/core.clj" was found on the classpath. Should this be a .cljs file?
There is a clj and a cljs file with the same name.

thheller19:03:07

@mynomoto which re-frame-10x version is that?

mynomoto19:03:55

[day8.re-frame/re-frame-10x "0.3.0-1-react16"]

danielo51519:03:19

But those methods are for spawning an standalone repl, I want to launch a watch and a repl attached to it.

thheller19:03:46

@mynomoto whats the global for react-highlight?

mynomoto19:03:45

(ns cljsjs.react-highlight
  (:require ["react-highlight.js" :as react-highlight]))

(js/goog.exportSymbol "Highlight" react-highlight)

mynomoto19:03:08

(ns cljsjs.highlight.langs.clojure
  (:require ["highlight.js" :as highlight]
            ["highlight.js/lib/languages/clojure" :as c]))

(.registerLanguage highlight "clojure" c)

mynomoto19:03:39

You will need the other one too. But all of those are not really tested because compilation failed before I could check

thheller19:03:04

odd. this does work in CLJS?

thheller19:03:20

the re-frame-10x code require is with an underscore

thheller19:03:32

but the provided namespace is with -

thheller19:03:04

so mranderson047.reagent.v0v8v0-alpha2.reagent.core is available but mranderson047.reagent.v0v8v0_alpha2.reagent.core is not

mynomoto19:03:44

That makes sense. I will try with a fixed version on my project.

thheller19:03:45

this shouldn't work in CLJS. don't know why it does

mynomoto19:03:12

I didn't test outside shadow.

mynomoto19:03:47

Adding a version with the correct namespace works. Thank you @thheller!

thheller19:03:41

do you still want to open the PR for those namespaces above so you get the "credit" (whatever that means)?

thheller19:03:46

or should I just add them?

thheller19:03:00

the shadow-cljsjs ones

mynomoto19:03:54

I will check if those are even working before opening the pr. I can do that now that the project is compiling.

thheller20:03:53

right. thx.

mynomoto20:03:42

Is there a way to add a dependency for production only on shadow?

thheller20:03:14

this doesn't really apply to shadow-cljs since your build decides what goes into it. not your dependencies.

thheller20:03:44

eg. :preloads are not included in a release build therefore if doesn't matter if you have them on the classpath

mynomoto20:03:59

Can you take a look at https://github.com/Day8/re-frame-debux#two-libraries ? It's a dependency only for side effects on clojurescript.

mynomoto20:03:40

It replaces the implementation of a tracing version of defn and fn but I'm not sure about how to do that using shadow.

thheller20:03:04

wait what? this stuff replaces things on the classpath?

thheller20:03:25

I guess you could fallback to deps.edn for this currently

thheller20:03:09

I don't get what is happening. why is that split into two libraries. the runtime overhead of doing one thing or another in the macro is tiny.

danielcompton11:04:25

The macro that is created is pretty large, when you expand it out. We made two libraries so you didn’t need to include any of the dev dependencies and you could be 100% sure there was no extra code ending up in your prod build

danielcompton11:04:03

I have a feeling the :devcards true trick will not be safe under the new AOT cache?

danielcompton11:04:57

I’m happy to hear other approaches for solving this problem

mynomoto02:04:23

I think I'm missing something simple here. Why wouldn't a closure define work to make the macro do what is done in the two libraries separately?

danielcompton02:04:36

We make the separate stub library so that you can be absolutely sure that the extra code doesn't get included

danielcompton02:04:50

The DCE does ensure that, but this felt like a safer way to do it

danielcompton02:04:04

You don't have to use the tracing-stubs library I guess, as long as the closure-define isn't set

danielcompton02:04:11

It will default to not running

mynomoto18:04:04

Yeah, I see what you mean but shadow doesn't have a native way of having different development/production dependencies, I would have to add another tool for that.

danielcompton19:04:08

Sure, we’ll you should be fine just using the tracing library then

thheller20:03:23

> With this setup, your use of both macros will have zero runtime and compile time cost in production builds, and are able to be turned off at dev time too via the Closure define. This ensures that you can leave your code instrumented at all times, but not pay any costs in production.

thheller20:03:51

there are other ways besides :closure-defines to achieve this though

thheller20:03:12

devcards does this via :devcards true

mynomoto20:03:35

Let me try to invoke @danielcompton about this 🆙