Fork me on GitHub
#shadow-cljs
<
2021-11-18
>
thheller06:11:55

@slack1338 no, that is only setup to require exports

Joshua Smock11:11:05

To give a little bit of context, I’m looking into other ways to combine CLJS and Jest. Jest supports ESM and has some nice advantages to using those files. As an alternative, would it be possible to configure the :js-options :js-provider for the :npm-module target? I tried to but it didn’t seem to work and I’d like to be able to set it to :import so that it uses import("./some-file") rather than require(…)

thheller17:11:40

:npm-module only outputs commonjs so it cannot use import

henryw37410:11:59

Hi, I have a vanilla browser-test setup working and I visit the browser-test page on localhost. When I remove the config from shadow-cljs.edn and invoke the api like this:

(shadow.cljs.devtools.api/watch
    {:build-id :test
     :target    :browser-test
     :test-dir  "target/public/js/test"
     :devtools  {:http-port          8021
                 :http-root          "target/public/js/test"}} 
    {:verbose false})
the watch appears to start normally, but there is no browser-test server started. is there something else I need to do when using the api to make this work?

henryw37414:11:51

I see it's getting the config from file, rather than using what was passed in to start shadow server https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/dev_http.clj#L380

henryw37414:11:06

ended up alter-var-rooting the get-server-configs var in that ns. I think I can get by with just dev servers passed at top level, so if it used the server config passed in to start the shadow server, rather than reading from the file, that would work in that case at least

thheller17:11:55

can you explain a little bit what you are doing? http servers are not coupled to builds and all http related :devtools config is deprecated. I just still allow it to not break old templates and such

henryw37406:11:58

sure. briefly, I am using shadow via api functions. my shadow-cljs.edn file is currently empty. I call the function to start the main server, then call things like watch that I posted an example of. this is because we have many builds across many projects and so benefit from sharing boilerplate via code. we could write out shadow-cljs.edn files and then invoke api calls with build ids and so on but since I can pass in config directly to the functions that seems preferable. the pr still means changes from shadow-cljs.edn are picked up as it is changed - everything still works. it just also means the config from the initial call to start the main server (whether passed as arg or got from shadow file) is used to start dev servers

thheller06:11:05

:dev-http is nothing but a simple static webserver. when you start your "main server" I assume that already has a webserver? why not use that?

henryw37406:11:51

by main server , I mean the shadow one, which has the dashboard ui. yes if I could get that to serve some resources of my choosing, that would work

henryw37406:11:32

... while keeping the shadow dashboard working under / ofc

thheller06:11:21

no I meant something like jetty or whatever webserver you are using?

thheller06:11:45

most people that go with this type of total custom setup (ie. no shadow-cljs.edn) tend to use their own servers?

henryw37406:11:44

oh I see. yeah that's a possibility. I'd rather configure it as per the shadow guide though. It makes it easier for others to follow

henryw37407:11:18

to be clearer about what I mean about getting shadow to use the config passed in to the main server, I mean I want the args I pass to shadow.cljs.devtools.server/start! to make it through to the dev-http stuff. that's what the pr achieves, while keeping the watch on shadow-cljs.edn working

thheller07:11:42

decided to clean it up a little more than your pr did

henryw37407:11:52

awesome :thumbsup: . thanks

thheller07:11:36

released in 2.16.5

thheller07:11:34

also updated https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test to make it not use http-root given its deprecated status