Fork me on GitHub
#shadow-cljs
<
2017-11-08
>
Jon02:11:39

I don't think dynamic import is a perfect solution either. Just sometimes sites go too large, no other solutions left.

thheller06:11:04

@jiyinyiyong I thing :modules and shadow.loader are pretty good solutions for this but ultimately it is up to the developer of each app

Jon10:11:34

agreed. just as I said, I have to make sure it doesn't break filename hashing

thheller06:11:39

if your app requires 3mb JS to even run you are doing it wrong. splitting it into smaller parts that then get loaded “dynamically” but still all need to be loaded for your app to work is basically the same as loading everything at once.

thheller06:11:41

in my experience the best optimization is using <script src="..." async> or defer. together with <link rel="preload"> (or h2 push) to let the browser start the download early.

thheller06:11:48

if you have a blocking script you are doing it wrong

mhuebert09:11:37

I’m getting this build error when evaluating things in a cljs REPL, and then saving the same file:

[:browser] Build failure:
symbol re-view.hiccup.core already provided by [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], conflict with [:shadow.cljs.repl/resource re-view.hiccup.core]
{:provide re-view.hiccup.core, :conflict [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], :resource-id [:shadow.cljs.repl/resource re-view.hiccup.core]}
ExceptionInfo: symbol re-view.hiccup.core already provided by [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], conflict with [:shadow.cljs.repl/resource re-view.hiccup.core]

thheller09:11:30

hmm interesting

thheller09:11:22

ah you are using watch combined with the REPL?

thheller09:11:26

so first loading (ns re-view.hiccup.core) via REPL, than saving the file and watch loading it again?

thheller09:11:58

typically I do not recommend using both

thheller09:11:27

in the REPL I usually want to be in control of what gets loaded, the live-reload just gets in the way at that point

mitchelkuijpers09:11:03

I am finding out that if I change my entry point that I don't get the pprint error. I am suspecting fulcro to be the problem then

thheller09:11:02

let me check that then 🙂

mitchelkuijpers09:11:37

I am just trying out namespaces untill it breaks ^^

mitchelkuijpers09:11:50

I love how fast the npm version is of shadow-cljs

thheller09:11:19

its even faster if you leave a shadow-cljs server running somewhere. only need to restart that if you change dependencies currently.

mitchelkuijpers09:11:43

Oh nice, but I will still put it into leiningen probably

thheller09:11:27

that will make the shadow-cljs command use lein to start things

thheller09:11:33

:lein true is enough, if you don’t want the custom profile

mitchelkuijpers09:11:35

Yeah already found it

mitchelkuijpers09:11:57

We should work on a good shadow-cljs website, do you need any help? I fixed the fulcro website a few weeks ago

thheller09:11:22

I need all the help I can get when it comes to documentation

mitchelkuijpers09:11:38

I might take a stab at it this project deserves more attention

mitchelkuijpers09:11:51

Writing docs is extremely hard

thheller09:11:26

didn’t start a real website yet but could be done if useful

thheller09:11:11

[fulcrologic/fulcro "1.0.0"] this?

mitchelkuijpers09:11:38

But I have it working now if I first compile a different NS and then the one I want

mitchelkuijpers09:11:25

That is not something I like hmm

thheller09:11:02

ok one thing that is immediately bad

thheller09:11:33

if uses https://clojars.org/clojure-future-spec and that should be excluded since we are on clojure 1.9 anyways

thheller09:11:53

(hopefully we are, that would be another probelm otherwise)

mitchelkuijpers09:11:26

Ok I excluded this, I think we are on the correct clojure version since I am using the npm version

thheller09:11:47

whats the ns to include for fulcro?

mitchelkuijpers09:11:41

[fulcro.client.core :as core]

mitchelkuijpers09:11:15

This is the complete NS btw:

(ns atlas-crm.ui.entry-points.spa-main
  (:require [atlas-crm.ui.entry-points.spa :refer [app]]
            [fulcro.client.core :as core]
            [atlas-crm.ui.root :as root]))

(reset! app (core/mount @app root/Root "app"))

mitchelkuijpers09:11:39

If try to compile the atlas-crm.ui.entry-points.spa that also fails so that might be the problem

thheller09:11:31

The required namespace “yahoo.intl-messageformat-with-locales” is not available, it was required by “fulcro/i18n.cljc”.

mitchelkuijpers09:11:41

Yeah i fixed that

thheller09:11:51

ah its on npm

mitchelkuijpers09:11:13

(ns yahoo.intl-messageformat-with-locales
  (:require ["intl-messageformat" :as intl-messageformat-with-locales]
            [goog.object :as gobj]))

(gobj/set js/window "IntlMessageFormat" intl-messageformat-with-locales)

mitchelkuijpers09:11:24

If you want I can try to make a minimal reproduction

mitchelkuijpers09:11:30

So I am not wasting your time

thheller09:11:55

that always helps 🙂

thheller09:11:49

but I kinda want to go through the process myself to see what people need to do to get this running

thheller09:11:55

and see if I can automate some of it

thheller09:11:24

normal CLJS libs should just work without too much effort

mitchelkuijpers09:11:16

Ah ok, I'll be back in about 30 minutes

thheller10:11:04

mostly the cljsjs.react and cljsjs.react.dom helpers since om is stil using js/React.createClass and js/React.DOM.h1 etc

thheller10:11:09

guess you did those as well?

thheller10:11:24

but I only included the sources, I didn’t actually use any of them

thheller10:11:28

pprint still works though. no warnings either.

thheller10:11:13

ha! spoke too soon, I still had the cached cljs.pprint

thheller10:11:18

deleted the cache and got the warnings

thheller10:11:41

looking into that now

thheller10:11:19

14sec to compile om.next .. wonder what crazy things that ns is doing … scared to look 😛

thheller10:11:06

haha .. found it

thheller10:11:45

(:require [clojure.pprint :refer (pprint)]) causes it … thats what you get when trying to take a shortcut in the alias code 😛

thheller11:11:29

I even left a note for this when I used the shortcut

thheller11:11:27

I have question, which I guess applies to everyone @mhuebert

thheller11:11:08

when working with the REPL, should watch become “passive”? as in not reload files automatically?

thheller11:11:10

it is currently possible to start dev worker in passive mode by calling (shadow/watch :your-build {:autobuild false})

thheller11:11:19

but not from the commandline

thheller11:11:52

I guess I have only done the REPL-first development when using shadow-cljs node-repl

mhuebert11:11:59

hmm. related question, when I try the ‘Load file in REPL’ command in cursive, it says “TBD” and I think i have to restart the repl. do you know if this is expected, and if it is on the cursive or shadow-repl side?

thheller11:11:03

which never watches

thheller11:11:50

thats me. the nrepl code is a bit broken for this.

thheller11:11:02

it works when you use the socket repl but cursive doesn’t support that natively 😞

thheller11:11:55

nrepl is general is pretty darn messy but I wanted to work on that anyways

mhuebert11:11:11

for me i’m usually not thinking in terms of watch or repl in a modal sense. i am making changes throughout the project and saving the files (and using git, etc), and periodically opening a REPL just to work on a small thing

thheller11:11:27

hmm yeah but thats why I’m asking

thheller11:11:47

when you actually start using the REPL, should watch become “passive”?

thheller11:11:25

otherwise you run into issues like before where a namespace defined at the REPL clashes with something in a file

thheller11:11:54

I can certainly fix this so it doesn’t cause an error and just loads the file

thheller11:11:07

but it basically overwrites everything you did in the REPL by loading it from disk

thheller11:11:38

but I guess its fine since you probably eval’d the same stuff anyways

mhuebert11:11:06

personally that is what i would have expected to happen, but i may have a less repl-driven workflow than others

thheller11:11:38

my CLJS workflow isn’t REPL driven at all, thats why I never got into this situation before

thheller11:11:57

for CLJS I usually have a watch running and just very occasionally poke at it with the REPL

thheller11:11:04

never defined an ns before though

thheller11:11:36

I’ll fix load-file first, then I’ll spend some time thinking about the other thing

mitchelkuijpers12:11:08

That seems to work @thheller nice find!

mitchelkuijpers12:11:19

Btw with Figwheel watch keeps working even when we are connected with a repl, which actually kinda works

thheller12:11:02

that also works for shadow-cljs, the question was whether that should be changed

mitchelkuijpers12:11:47

Ah ok, for me it kinda works because I mostly use the repl to get autocomplete in emacs 😛

thheller12:11:39

yeah its fine for those things

mitchelkuijpers16:11:09

Is there a way to use shadow/repl or shadow/dev with nrepl?

thheller16:11:56

yeah its the shadow.cljs.devtools.api namespace. can’t figure out how to make cursive use shadow.user ns.

thheller16:11:22

(require '[shadow.cljs.devtools.api :as shadow]) and you are good to go 😉

mitchelkuijpers16:11:24

If i try (shadow/watch :app) it says missing instance

mitchelkuijpers16:11:44

I try this from a nrepl connection from a connected repl

mitchelkuijpers16:11:59

I saw this note: This DOES NOT WORK while in nREPL unless your nREPL client supports needs-input.

thheller16:11:02

ah you are in lein repl?

mitchelkuijpers16:11:45

Yes pretty much, I start it from within emacs

thheller16:11:40

I recommend that you set :nrepl {:port some-number} in shadow-cljs.edn

thheller16:11:54

then connect to that if possible with emacs?

mitchelkuijpers16:11:57

Ah and then just connect?

thheller16:11:20

you can also embed the server though

mitchelkuijpers16:11:55

You mean embed the server which starts an nrepl server? I woul prefer that tbh

thheller16:11:06

I have this in the project itself

thheller16:11:42

and a hotkey in cursive that just sends (require 'repl) (repl/go) to the REPL

mitchelkuijpers16:11:48

What I actually tried to do is start 3 workers when I start my dev env

thheller16:11:02

shadow-cljs watch a b c

thheller16:11:47

or like the above also works

mitchelkuijpers16:11:53

I'll play around with just connecting I do like that the npm version is so damn fast with trying stuff out and restarting

thheller16:11:34

I still think its too slow but a whole lot better than lein yes 😉

mitchelkuijpers16:11:57

And I don't have to play dependency puzzle with shadow-cljs

thheller16:11:00

you probably need to do the exclusions there too though

thheller16:11:04

please let me know if emacs doesn’t work properly

thheller16:11:24

I really want this to work but I don’t know enough about emacs to test it myself

mitchelkuijpers16:11:41

I use cider not sure if you want to support that?

thheller16:11:51

it should be supported

mitchelkuijpers16:11:11

should I do:

:nrepl {:port 3002
         :middleware
         [cider.nrepl.middleware.apropos/wrap-apropos
          cider.nrepl.middleware.classpath/wrap-classpath
          cider.nrepl.middleware.complete/wrap-complete
          cider.nrepl.middleware.debug/wrap-debug
          cider.nrepl.middleware.format/wrap-format
          
          cider.nrepl.middleware.inspect/wrap-inspect
          cider.nrepl.middleware.macroexpand/wrap-macroexpand
          cider.nrepl.middleware.ns/wrap-ns
          cider.nrepl.middleware.pprint/wrap-pprint
          cider.nrepl.middleware.pprint/wrap-pprint-fn
          cider.nrepl.middleware.refresh/wrap-refresh
          cider.nrepl.middleware.resource/wrap-resource
          cider.nrepl.middleware.stacktrace/wrap-stacktrace
          cider.nrepl.middleware.test/wrap-test
          cider.nrepl.middleware.trace/wrap-trace
          cider.nrepl.middleware.out/wrap-out
          cider.nrepl.middleware.undef/wrap-undef
          cider.nrepl.middleware.version/wrap-version]}
I am playing around with that

thheller16:11:37

yes if you want to use that. guess its needed if you want to use some cider features

mitchelkuijpers16:11:00

Yeah but it seems to break stuff

mitchelkuijpers16:11:16

[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
NullPointerException: 
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        shadow.cljs.devtools.server.nrepl/start (nrepl.clj:243)
        shadow.cljs.devtools.server.nrepl/start (nrepl.clj:233)
        shadow.cljs.devtools.server/start-system (server.clj:129)
        shadow.cljs.devtools.server/start-system (server.clj:94)
        shadow.cljs.devtools.server/start! (server.clj:180)
        shadow.cljs.devtools.server/start! (server.clj:172)
        shadow.cljs.devtools.server/start! (server.clj:175)
        shadow.cljs.devtools.server/start! (server.clj:172)
        shadow.cljs.devtools.server/from-cli (server.clj:280)
        shadow.cljs.devtools.server/from-cli (server.clj:256)
        shadow.cljs.devtools.cli/blocking-action (cli.clj:98)
        shadow.cljs.devtools.cli/blocking-action (cli.clj:90)
        shadow.cljs.devtools.cli/main (cli.clj:139)
        shadow.cljs.devtools.cli/main (cli.clj:101)
        clojure.core/apply (core.clj:661)
        clojure.core/apply (core.clj:652)
        shadow.cljs.devtools.cli/-main (cli.clj:178)
        shadow.cljs.devtools.cli/-main (cli.clj:176)
        clojure.lang.Var.applyTo (Var.java:702)
        clojure.core/apply (core.clj:657)
        clojure.main/main-opt (main.clj:317)
        clojure.main/main-opt (main.clj:313)
        clojure.main/main (main.clj:424)
        clojure.main/main (main.clj:387)
        clojure.lang.Var.applyTo (Var.java:702)
        clojure.main.main (main.java:37)

thheller16:11:46

maybe the list is old and some namespaces have changed?

mitchelkuijpers16:11:47

Actually the only thing I want to work is autocompletion and a working repl for clojurescript 😛

mitchelkuijpers16:11:54

Yeah probably will check it out

mitchelkuijpers16:11:28

Oh I do remember something about how they made all middleware dynamic, will investigate further

thheller16:11:47

got the list from the readme

mitchelkuijpers16:11:56

Yeah but cider depends on the new snapshot

mitchelkuijpers16:11:17

:nrepl {:port 3002
         :middleware
         [cider.nrepl/wrap-apropos
          cider.nrepl/wrap-classpath
          cider.nrepl/wrap-complete
          cider.nrepl/wrap-debug
          cider.nrepl/wrap-enlighten
          cider.nrepl/wrap-format
          cider.nrepl/wrap-info
          cider.nrepl/wrap-inspect
          cider.nrepl/wrap-macroexpand
          cider.nrepl/wrap-ns
          cider.nrepl/wrap-out
          cider.nrepl/wrap-refresh
          cider.nrepl/wrap-resource
          cider.nrepl/wrap-spec
          cider.nrepl/wrap-stacktrace
          cider.nrepl/wrap-test
          cider.nrepl/wrap-trace
          cider.nrepl/wrap-tracker
          cider.nrepl/wrap-undef]}
This one seems to work

thheller16:11:43

that will probably kill your startup performance though 😉

thheller16:11:26

ah cool. they load is dynamically now. then it won’t be so slow.

thheller20:11:11

@mhuebert just pushed [email protected] with support for source maps in :bootstrap. not sure if you actually need them but it also fixed errors not showing proper locations you mentioned a few days ago.