Fork me on GitHub
#shadow-cljs
<
2023-11-02
>
hifumi12305:11:22

@thheller regarding updating the gcc version: exactly 1 test in clojurescript master branch fails when using v20230802, so we may want to wait before using this version in shadow-cljs.

lein test :only cljs.build-api-tests/cljs-2077-test-loader

ERROR in (cljs-2077-test-loader) (Reflector.java:416)
Uncaught exception, not in assertion.
expected: nil
  actual: java.lang.IllegalArgumentException: No matching field found: sourceMapOutputPath for class com.google.javascript.jscomp.CompilerOptions
 at clojure.lang.Reflector.setInstanceField (Reflector.java:416)
    cljs.closure$make_options.invokeStatic (closure.clj:355)
    cljs.closure$optimize_modules.invokeStatic (closure.clj:1448)
    ...
    cljs.build_api_tests/fn (build_api_tests.clj:207)
    ...

hifumi12306:11:59

this patch is sufficient to fix the test and make everything succeed… what I find strange is that the field CLJS is attempting to set has been private for over a year… so why would it pass in the may version but not the august version??

thheller07:11:43

shadow-cljs does not use the cljs.closure namespace, so we might be fine

thheller07:11:16

cljs itself is probably still depending on a much older version?

thheller07:11:39

[com.google.javascript/closure-compiler-unshaded "v20220502"]

thheller07:11:34

but even that I think is unreleased

hifumi12307:11:53

good catch, i didn't read the year correctly. given what you've said about shadow-cljs not using cljs.closure, then all that is left is to test shadow-cljs itself

Lone Ranger17:11:15

is there a way to choose aliases per build, and per release/dev?

erwinrooijakkers12:11:28

I am depending on a library, but also want to move images from that library into the resources/public/images folder. I thought about using a build hook to move the images, but is there another way as well?

Chris McCormick12:11:27

Can you use a symlink into node_modules ?

erwinrooijakkers12:11:03

the library depended on is in our own control as well by the way

erwinrooijakkers12:11:53

preferably the interface is such that we only add that library in our project.clj and the resources are shared, but can imagine this is blocked for security reasons or so

erwinrooijakkers12:11:02

maybe by adding something like

:resource-paths ["src/resources" "path/to/library/resources"] 

thheller12:11:53

if this is a clojure library you can just keep the files in the jar

thheller12:11:57

no copying needed

thheller12:11:51

:dev-http {8080 "classpath:public"} will find things in the jar

erwinrooijakkers12:11:25

thanks! and for a release build?

thheller12:11:45

uhm I assume you have a server of some kind?

thheller12:11:56

otherwise yes, you need to copy things out

erwinrooijakkers12:11:59

yes nginx just serves

thheller12:11:10

ah ok, I assumed some kind of clj server

erwinrooijakkers12:11:12

ah okay so for that i do need a build step

thheller12:11:20

I do not recommend a build hook though

ingesol14:11:48

I’m using this in my .clojure/deps.edn

:main-opts ["-m" "shadow.cljs.devtools.cli" "--config-merge" "{:devtools {:preloads [my-preload]}}"]
My problem is that I need the preload to replace the preloads vector in the project deps.edn, not add to it. Is there a way to do that?

thheller16:11:27

I guess my question is why is this in .clojure/deps.edn?

ingesol17:11:16

Plugging in random dev tooling from outside the project

thheller17:11:27

is it your project? or can you change the project?

ingesol17:11:37

it’s mine, yes

ingesol17:11:11

the current approach is to keep the tooling strictly out of the main project. If that’s impossible, I’ll consider alternatives

thheller17:11:25

that doesn't match what you asked earlier about replacing :preloads?

thheller17:11:50

the answer is that there is currently no way to replace this

ingesol17:11:58

there’s one preload that is currently pre-configured in shadow-cljs.edn.

thheller17:11:04

doesn't mean there can't be but I want to understand the use case before considering anything

ingesol17:11:18

So to be more specific and concrete, we have: 1. A preload for a dev tool in the project 2. Per-dev tooling that require preloads. Some require a certain order relative to the pre-configured one

thheller17:11:15

that order you can establish by having the namespace itself require the other

thheller17:11:55

(ns foo.preload2 (:require [foo.preload1])) even with :preloads [foo.preload2 foo.preload1] this ensures that 1 loads before 2

ingesol17:11:45

yeah, but since all of these except the pre-configured one are optional, they can’t really require each other

ingesol17:11:03

I’ll think about this, there may be an angle in the require idea

ingesol17:11:46

I could also add all tooling as aliases in project deps.edn. There’s still the issue of how to compose the preloads in config-merge

thheller17:11:01

can you specify what these preloads do in the first place? I guess I don't quite get what they do

ingesol17:11:26

or have a script that launches shadow, and solve this on the CLI by having the default watch startup provide --config-merge {:preloads [default-preload]}

ingesol17:11:23

• Malli function instrumentation init • Malli clj-kondo config generation watcher • Flow-storm debugger • Hashp logging tool Where Flow-storm is optional, and has to be first if it’s included

thheller17:11:29

I guess you could use a build hook. thats just CLJ code that can do pretty much anything

ingesol18:11:29

We have a script that sets up parameters for shadow-cljs, I managed to fix it there by specifying aliases and preloads, with defaults. That does what we need. Thanks a lot for talking through this with me!

Lone Ranger22:11:45

Is it possible to have different aliases per build and per dev/release?

Lone Ranger22:11:37

the :flow-storm alias has the flow-storm code, but I do not want the flowstorm code in the release build.

Lone Ranger22:11:14

the problem I'm encountering is that when run via cider, the only aliases that seem to be respected are the ones used in the top level :deps -> :aliases path

thheller07:11:02

you are looking at the wrong piece of configuration

thheller07:11:14

the only thing that controls what ends up in your build is your code and build config

thheller07:11:33

thus if you require any flowstorm related code in your namespaces it will be part of your build

thheller07:11:55

same when putting it in your build config, besides :preloads

thheller07:11:15

deps.edn or aliases are not relevant to this in any way as a required namespace is always required and not optional

thheller07:11:02

:preloads btw are only applied to watch/compile builds, not release

thheller07:11:18

so you can just leave it in the config for release builds, it won't affect the build

thheller07:11:41

you can verify the structure of your build via build reports

thheller07:11:58

if you mouse over a file/namespace line it'll also tell you why it was in included

Lone Ranger20:11:19

Ok -- but my question was how can you selectively include aliases

thheller20:11:46

shadow-cljs does not support this since it breaks server mode

thheller20:11:06

you can launch via clj directly, and nothing is stopping you from using whatever aliases there

thheller20:11:36

so clj -A:whatever:aliases:you:like -M -m shadow.cljs.devtools.cli release app

thheller20:11:12

I'd recommend using your development aliases by default in shadow-cljs and running via clj directly for release builds

Lone Ranger20:11:45

Unless we can change deps on a per build basis, I'd need two different shadow-cljs files

thheller20:11:43

as I just explained. you can do whatever you want when running with CLJ directly. shadow-cljs itself does not and will not support defining per build aliases

Lone Ranger20:11:09

Ok, great 🙂 Does it support different shadow-cljs files? clj -A:whatever doesn't play as nicely with CIDER for me

Lone Ranger20:11:32

if not I'll work around it

thheller20:11:42

there is only one shadow-cljs.edn, not changable

Lone Ranger20:11:09

Ok, thanks 🙂