Fork me on GitHub
#shadow-cljs
<
2018-09-23
>
huygn11:09:33

hi, I'm trying to setup code splitting with below config. I have app.main which is an spa router and 2 pages (home & todo)

:modules {:shared {}
                          :main {:entries [app.main]
                                 :depends-on #{:home :todo}}
                          :home {:entries [app.pages.home]}
                          :todo {:entries [app.pages.todo]}}
however doing so yields two modules without deps, please specify which one is the default. but those 2 pages dont really depends on anything except rum. Am I missing something here? :thinking_face:

Jakub Holý (HolyJak)06:09:36

perhaps the error message could be improved? I too got it and was baffled, @thheller; perhaps: > two modules without deps, perhaps they should both depend on a third, "shared" module (with empty entries)? see <url to docs for this>

thheller12:09:18

@gnhuy91 you need to specify a shared module. so its probably the reverse. :home depends-on #{:main} as well as todo depends on #{:main}

thheller12:09:13

app.main will always be loaded and home and todo on demand. so they depend on :main

👍 4
huygn12:09:23

arh thanks! so I misunderstood it there 👌

huygn18:09:00

hi, on "loading code dynamically", how can I access to the loaded module? (loader/load "extra") resolver only indicate loaded/failed status and does not return the module itself. (in webpack it is import(() => "./foo").then(foo => foo.default))

thheller19:09:10

well thats where it gets a bit tricky

thheller19:09:45

the namespaces that are part of the module you loaded are accessible

thheller19:09:59

but the compiler doesn't handle this very nicely

thheller19:09:26

you can use resolve to get to a function you defined

thheller19:09:43

((resolve 'your.ns/foo) 1 2 3)

thheller19:09:02

would basically call (your.ns/foo 1 2 3)

huygn19:09:42

let me try, thanks!

huygn19:09:39

mindblow 🤯 , it works

huygn19:09:12

more tricky than i thought, was building a loadable component wrapper to handle dynamic rum components

huygn19:09:24

thank alots 🙏

thheller19:09:45

yeah closure handles modules statically so it works a bit differently than in webpack

👍 4
lilactown21:09:42

is there any analyzer metadata I can get out of a bootstrapped environment?

lilactown21:09:12

I’m trying to get line number and position of a particular token (e.g. a path into a map)

thheller21:09:57

you can modify cljs.tools.reader to do what you need

thheller21:09:21

it doesn't keep line/col metadata on keywords by default

lilactown21:09:37

does it keep line/col metadata on other values?

thheller21:09:25

edn reader no. cljs reader yes

thheller21:09:41

not on keywords, numbers, strings, bools

thheller21:09:44

maybe this helps. I tried something related a while ago https://dev.clojure.org/jira/browse/TRDR-42

lilactown21:09:59

:thinking_face: is there something I’m doing wrong here?

(-> (reader/read-string "{:foo 5
                          :bar [1 2 3]}")
    (meta))
comes back as nil

thheller21:09:25

you are using the EDN reader

lilactown21:09:55

(require ...
            [cljs.tools.reader :as reader])
?