Fork me on GitHub
#shadow-cljs
<
2020-11-19
>
mruzekw00:11:39

Is there a way to alias a namespace per build? So two builds would use the same namespace in the code, but when built are replaced with aliased namespaces

thheller08:11:23

@mruzekw you can set :build-options {:ns-aliases {my.app.foo my.app.bar}}. that will make it use .bar whenever .foo is required in the build

mruzekw23:11:12

Nice! Thank you!

thheller09:11:50

@jag I can't tell what is going on but the package doesn't seem to be bundle-able. looks like you are supposed to directly include it via a script tag

thheller09:11:51

I mean it even has tons of custom instructions for webpack. doesn't even work out of the box there. https://docs.mathjax.org/en/latest/web/webpack.html

thheller09:11:29

the mathjax package seems to be targetted for node only

Jag Gunawardana10:11:32

Thanks @thheller. Sorry if this was obvious. My JS knowledge needs a bit of a turbo boost.

thheller10:11:14

not at all obvious. quite the opposite actually.

ingesol11:11:53

Hi! I’m having issues making Leaflet work in the build I’m trying to convert. The issue is that some plugin of Leaflet refers to the global L variable that is traditionally exposed by leaflet. The NPM version of leaflet does not expose the global. In another lein project I fixed this by running webpack, with the following tweak:

new webpack.ProvidePlugin({
      // Leaflet markercluster plugin requires global L object.
      L: 'leaflet'
    }),
Is there some way of solving this naturally in shadow-cljs? Seems like I could change my :js-provider, but that would kind of remove the point of moving to shadow-cljs. Maybe create my own cheat where I make a new module that requires leaflet and exposes the global?

thheller11:11:14

@ingesol :js-options {:resolve {"leaflet" {:exports-globals ["L"]}}} in the build config might do the trick. or just (js/goog.exportSymbol "L" L) with (:require ["leaflet" :as L]) somewhere before the plugin is loaded

ingesol11:11:22

@thheller Thanks! Will try

ingesol13:11:10

worked nicely with that export-globals thing. Tried to find it in the docs, seems undocumented for now?

thheller13:11:28

might be yeah. very rare thats actually needed.

defa14:11:21

Having react-native as a target, when I'm connected to "on device repl" (`(shadow/repl :app)`), I'm having a string encoding issue. when using println in the REPL all non ASCII chars are ? any idea on how to fix that?

thheller16:11:56

@defa shadow-cljs uses unicode everywhere so this should be fine. did you try shadow-cljs cljs-repl app directly and check if it happens there too? if so it is your connection to the other REPL

misha16:11:28

@thheller hi, might be useful for you and others: https://akovantsev.github.io/corpus/shadow-cljs this is aggregated slack log on a single page, rather than spread across hundreds of 1-day=1-page files at https://clojurians-log.clojureverse.org/shadow-cljs/

😎 6
wiseman18:11:12

I must be doing something wrong. I have a simple app build:

{:app
  {:target :node-script
   :output-to "out/server.js"
   :main com.disney.rant-lsp/main
   :compiler-options {:infer-externs true}}
  :test
  {:target :node-test
   :output-to "out/node-tests.js"
   :compiler-options {:infer-externs false}
   ;;:ns-regexp "-spec$"
   :autorun true}}
I do npx shadow-cljs compile app. The app runs fine, until I package it (it’s a VS Code extension). The packaging doesn’t include the .shadow-cljs directory. This used to work, but recently I started getting this:
Error: ENOENT: no such file or directory, open '/Users/wisej041/.vscode/extensions/wdi.rant-1.0.2/server/.shadow-cljs/builds/app/dev/out/cljs-runtime/goog.debug.error.js'

wiseman18:11:54

I didn’t think I had to include .shadow-cljs; is that correct?

thheller18:11:34

@wiseman you need to run shadow-cljs release app if you want to publish something. compile and watch are development builds only meant to run on the machine they were compiled on

thheller18:11:01

@misha yikes that file is gigantic. doesn't seem very practical to me. where did you get the data?

misha19:11:02

It is practical, but for staying open in a tab, not for getting open willy-nilly every few minutes :) Data is from scraped second url, clojureverse one

misha19:11:42

Try doubleclicking words, you’ll see what I mean

isak20:11:52

The other one is not practical, because it is not 100% indexed by google. I had to download all the files and write a script to find stuff. So for me this one is much better, even if it is a little big.