shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
mruzekw 2020-11-19T00:44:39.088400Z

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

thheller 2020-11-19T08:50:23.089300Z

@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

thheller 2020-11-19T09:02:50.090Z

@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

thheller 2020-11-19T09:05:51.090600Z

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

thheller 2020-11-19T09:06:29.090900Z

the mathjax package seems to be targetted for node only

Jag Gunawardana 2020-11-19T10:07:32.091900Z

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

thheller 2020-11-19T10:09:14.092400Z

not at all obvious. quite the opposite actually.

ingesol 2020-11-19T11:07:53.095200Z

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?

thheller 2020-11-19T11:54:14.096500Z

@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

ingesol 2020-11-19T11:55:22.097100Z

@thheller Thanks! Will try

ingesol 2020-11-19T13:02:10.097900Z

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

thheller 2020-11-19T13:04:28.098200Z

might be yeah. very rare thats actually needed.

defa 2020-11-19T14:48:21.100500Z

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?

thheller 2020-11-19T16:02:56.102100Z

@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

misha 2020-11-19T16:49:28.104Z

@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/

😎 2
2020-11-19T18:24:12.105900Z

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'

2020-11-19T18:26:54.107Z

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

thheller 2020-11-19T18:39:34.107700Z

@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

thheller 2020-11-19T18:41:01.108300Z

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

2020-11-19T18:42:23.108500Z

thanks, @thheller!

misha 2020-11-19T19:25:02.111900Z

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

misha 2020-11-19T19:26:42.113100Z

Try doubleclicking words, you’ll see what I mean

isak 2020-11-19T20:47:52.114500Z

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.

mruzekw 2020-11-19T23:41:12.115400Z

Nice! Thank you!