there is a --test= argument for the compiled tests
if the target is node-test
hello, is there any need to have test dependencies in any way separated from the other (runtime) dependencies. Will shadow-cljs automatically remove unused dependencies when I run shadow-cljs release app
?
@franklineapiyo your builds only include whatever you :require
in your namespaces. having extra :dependencies
does not matter when they are not required in your build directly. generate a build report to see what ended up in your build and why https://shadow-cljs.github.io/docs/UsersGuide.html#build-report
thanks
Hello, channel! I am trying to generate a js with a hash for my project, but it seems I have no idea how to dynamically include a hashed js file into an html. How do I make sure that my index.html file includes the latest module with a hash if I use
:module-hash-names
?I have tried that approach but it looks like unfortunately it doesnt work
Unless I am missing something
no way for me to tell without seeing what you did 😛 I know that the implementation works since I use it
basically you need to have a source html file that has <script src="/js/base.js"></script>
tag already
all the copy does is replace the src path, and only if the source path matches you configured :asset-path
+ the module name
right ... Ill try to double check! Thanks for coming back to me so quickly!
looks like I have the setup correctly, but it still doesnt do the desired thing ...
what is your :asset-path
? what is your script src
? and what is your :build-hooks
config?
not that many things affect this so should be easy to find
I have src/index.html
file that contains <script _src_="js/compiled/main.js" _type_="text/javascript"></script>
tag. I have shadow-cljs.edn
that has
:frontend
{:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
;; :compiler-options {
;; ;; add env vars
;; }
:build-hooks [(shadow-env.core/hook)
(shadow.html/copy-file
"public/src/index.html"
"public/index.html")]
:module-hash-names true
;; ;; :fingerprint true
;; :build-options {:manifest-name "manifest.json"}
:modules {:main
{:init-fn mytherapy.core/init!}}
;; :compiler-options {:externs ["public/js/plugins/"]}
}
well there you have it 😛
you have :asset-path "/js/compiled"
but use script src="js/compiled/main.js"
that needs to match, so switch either
like (not (= "/js/compiled" "js/compiled))
type of match?
yes, exact match. not only for the purpose of this hook, they should always match
I dont know, if I switch to <script _src_="/js/compiled/main.js" _type_="text/javascript"></script>
and :output-dir "public/js/compiled" and :asset-path "/js/compiled" they do not seem to affect the behaviour
https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html
hopefully the second part about output paths and http makes that a bit clearer
thanks! Ill read into it!
very likely you want :asset-path "/js/compiled"
and script src="/js/compiled/main.js"
that is literally what I have
ok, actually, needed to clear cache
now it works
With the paths being identical!
Thanks a lot! Very useful tip!
I am trying to get a selmer workaround
you can use the manifest to generate the HTML you need https://shadow-cljs.github.io/docs/UsersGuide.html#BrowserManifest
or you can use this hook https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L150-L152
it'll copy the src html and rewrite the script src with the hashed names
i'm trying to fix an issue in a dep two levels down with an externs file. i can get the extern to work if i put the file in my repo and add it to :externs
but i'm trying to add it to the dep (via deps.cljs
in that jar) so that other projects can get it for free... but it isn't getting picked up that way. anyone know if this does or doesn't work? versions to use? pointers on debugging?
i'd love to have shadow-cljs print out what it's passing to the compiler... if that's even how it works 🙂
or does anyone know if {:externs ["file.js"]}
is enough... or does it need foreign-libs
to work? (from a jarred deps.cljs
)
the shadow build produces a jar manifest that has the externs file contents (in "~:resources"
), but the "~:externs"
is just []
... there aren't any other files in it though... it looks like it's treating it as a js module
confirmed, if i rename that file to .txt it no longer shows up in the manifest even though it's supposed to be in :externs
@clj149 shadow-cljs does not support externs via deps.cljs
and regular CLJS doesn't support the simplified .txt externs
ok, thanks
so any externs required must be in the project being built
yeah, libraries nowadays should really use ^js
hints when needed. that works in everything and is easier to maintain.
yeah, i've confirmed that that helps, but was trying to hack around external libraries if there was any magic way to do it
thanks