Fork me on GitHub
#shadow-cljs
<
2019-04-14
>
talgiat16:04:14

@thheller thanks for all the tips, got it working with the plugin. One thing I noticed is that I get multiple calls to shutdown with the plugin, not sure why. Another question is can I pass arguments to the plugin from the build config? It also seems the the plugins are set globally and not per build.

thheller17:04:02

@talgiat yes plugins are once per server. you can change :depends-on to :depends-on [:config] and :start (fn [config] ...)

thheller17:04:12

config is the shadow-cljs.edn content

thheller17:04:18

so you can add your own keys there

thheller17:04:41

:sass/config {:foo :bar} or so

thheller17:04:14

plugins can in theory access all server functionality and hook into anything. just none of it is documented. 😛

lilactown18:04:38

trying to use latest devcards, I get an error:

The required namespace "cljsjs.marked" is not available, it was required by "devcards/util/markdown.cljs".
The namespace was provided via :foreign-libs which is not supported.
Please refer to  fo more information.
I’m guessing this is devcards not specifying this correctly in deps.cljs. any work arounds?

talgiat18:04:48

@thheller thanks! I guess it’s semi documented, because I can read the source code 😁. Few other questions: so does the plugin knows which build is currently running? is it called before any build is invoked (just trying to understand the lifecycle of the whole build system and the point where plugins are called). Also did you run into cases where a plugin shutdown is called multiple times before?

talgiat18:04:13

Another question: can build hooks get access to the full shadow-cljs.edn content and not just the build state? (I guess I can use shadow.cljs.devtools.config/load-cljs-edn, but thought there might be something else)

thheller19:04:58

@talgiat build specific stuff should probably be in the build config which is at :shadow.build/config in the build state (passed into the hooks)

thheller19:04:27

plugin is started when the runtime is started. so in server-mode once. stop should only be called when the runtime is shutdown

talgiat19:04:37

I need the sass/config to be visible to the plugin and for a hook

talgiat19:04:52

That’s why I’m asking

thheller19:04:43

in the build hook you can get access to the full runtime via (shadow.cljs.devtools.server.runtime/get-instance!)

thheller19:04:03

thats a map that'll contain a :your.plugin-ns/plugin key

thheller19:04:11

which is the whatever was returned by :start

Nolan20:04:30

i have created a ~/.shadow-cljs/config.edn file with the following contents

Nolan20:04:43

{:proxy
 {:host "localhost"
  :port 8099}}

Nolan20:04:52

that is the proxy configuration i use for everything

Nolan20:04:10

however shadow-cljs still fails to resolve the dependencies

Nolan20:04:15

any help is appreciated

thheller20:04:55

does it work if you move the config into the shadow-cljs.edn? I changed how the global config is handled so that might not be working anymore?

Nolan20:04:10

i will try, please hold on

Nolan20:04:17

yes, that worked

Nolan20:04:24

thanks theller

Nolan20:04:49

although it is a bit unsatisfactory to have to commit my proxy configuration?

Nolan20:04:01

great, glad ur so active!

thheller20:04:07

should fix it soon. maybe a bit later. doing other stuff right now.

👍 1
Daniel Leong23:04:24

I'm interested in playing with shadow-cljs for a node module I'm working on, but I'm having trouble getting started with the repl. I've set the build :target to :npm-module and :runtime to :node, but after shadow-cljs watch lib and shadow-cljs node-repl I still get "No application has connected to the REPL server" when I try to evaluate forms over cider from Vim

Daniel Leong23:04:22

I imagine at some point there will be a bin component to it that I can set as :main and run, but primarily I want to architect this as a library, and hope to have the normal clojure repl experience evaluating forms and executing tests.

Daniel Leong23:04:25

Am I missing something?

thheller23:04:22

shadow-cljs watch lib and node-repl are completely unrelated

thheller23:04:21

if you want to REPL into teh` lib` build YOU need to launch a node process that loads the compiled code

thheller23:04:28

:main is not a thing for :npm-module

thheller23:04:50

what are you building?

thheller23:04:02

a CLI script? a library?

Daniel Leong23:04:13

Is require('./dist/whatever.core' not sufficient to load the compiled code?

thheller23:04:27

it is .. but for :npm-module its a bit trickier

Daniel Leong23:04:30

It’s a library that might also have a CLI mode if installed globally

thheller23:04:45

so you probably want to use :node-library instead

thheller23:04:23

OR in the .js files you do the require in you also require("./dist/shadow.cljs.devtools.client.node")

thheller23:04:49

this is taken care of by :node-library but must be done manually for :npm-module

Daniel Leong23:04:20

Oooh I see. I missed the part where it said :npm-module is intended to be part of the project

thheller23:04:03

docs are a bit outdated and incomplete

thheller23:04:12

if you want a normal clojure REPL experience just forget about build configs completely for now

thheller23:04:17

and just shadow-cljs node-repl

thheller23:04:07

and just use the :node-repl build id when selecting a REPL instead of :lib

thheller23:04:21

(assuming cider/vim supports that)

Daniel Leong23:04:38

Aha okay, interesting

thheller23:04:56

but that is as close as you'll get to "clojure REPL"

Daniel Leong23:04:12

I was able to connect to node with :node-library but I’ll also give the :node-repl thing a shot

thheller23:04:21

(meaning it won't watch source files at all, or hot reload anything ever)

Daniel Leong23:04:35

Thanks for your help!