Fork me on GitHub
#shadow-cljs
<
2023-06-20
>
thheller05:06:44

@grzegorz.rynkowski whether the workspaces dep is on the classpath or not has no effect for a release build, so just always having the :ws alias active is not a problem. a build only uses whats directly required by the code, not everything on the classpath. not sure why you'd need it to be disabled for release. you can always run a release build manually via clj or clojure, with whatever aliases you want though. npx shadow-cljs release app is equiv to clj -A:whatever:aliases -M -m shadow.cljs.devtools.cli release app

👍 2
thheller05:06:07

generally shadow-cljs has no option to selectively uses aliases because it isn't needed https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html

Alex H17:06:53

Hi folks - I have one .js file required locally from the classpath (i.e. not from npm) - it, however, also depends on some npm bits, etc. :advanced compilation seems to be making a dog's breakfast of it - externs aren't really being inferred, etc, and so method calls (& properties) are being renamed even though they have to be preserved because they are interop with some npm packages. Can I disable :advanced optimizations for the local js files, much like npm deps don't go through it? If not, is my best bet to write a manual externs file?

thheller18:06:03

if you write the file as commonjs it won't go through advanced

thheller18:06:15

but it also means it can't directly import CLJS code

thheller18:06:41

if you don't need it just rewrite import/export to require and module.exports

Alex H18:06:55

OK, I'll give that a try. I don't need to access cljs from it, so that bit is fine. Thanks!

thheller18:06:09

commonjs is processed just like any other npm code, but on the flip side your CLJS code accessing it might then need externs 😛

thheller18:06:32

but you should get proper warnings for those cases

Alex H18:06:46

The only other option would be an externs file, I guess?

Alex H18:06:44

Rewriting it as cjs seems to have done the trick, though. It's a bit hacky, but perfectly livable. Thanks!

👍 2
thheller18:06:01

externs would work too yes

oliver19:06:52

Hi everyone! I'm trying out the reader conditionals in order to make my project's config behave differently on Node vs. the browser. Here is what I have:

(ns config.env
  (:require #?@(:node [[config.server :as server]]
                :cljs [])))

#?(:node
   (defn setting [path]
     (let [result (get-in server/env pointer)]
       (when (nil? result) (js/console.warn "Got a nil config value for " pointer))
       result))
   :cljs
   (defn setting [pointer]
     :noop))
My node build, however, consistently uses the :cljs variant, the :node is ignored. What may I be doing wrong? Using Shadow-cljs 2.23.8 (directly from the Clojure CLI, not npm).

2
oliver20:06:18

Alright, this was a simple case of RTFM. I forgit to add the compiler option. :reader-features #{:node}