shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
dehli 2020-11-16T15:43:59.033300Z

Hi, I have a question about the :node-test target. Should releases using :node-test be minified the same way as :node-script? There’s a bug I’m getting when I run my tests if the code is generated using release . This is the issue for some more context (https://github.com/henryw374/cljs.java-time/issues/8)

thheller 2020-11-16T15:48:48.033800Z

do you have the build configs you used?

thheller 2020-11-16T15:59:20.035200Z

@dehli you can set :compiler-options {:externs ["cljsjs/js-joda/common/js-joda-dup.ext.js"]} in your build config to include the externs it seems to require. not sure why node-script works but node-test does not.

dehli 2020-11-16T16:02:41.037600Z

Great! sorry i didn’t see your earlier message but this was the build config I used https://gist.github.com/dehli/09599a4ed0040f7a03fea22ef02c4c89#file-shadow-cljs-edn I’ll make some more changes to the gist to try and isolate the issue but since it’s just for tests I’m fine doing compile instead of release . Thanks!

dehli 2020-11-16T16:04:06.038200Z

Also thanks for following up on the issue! That helps a lot!

thheller 2020-11-16T16:04:10.038300Z

compile doesn't go through :advanced so it will never have any externs related issues.

👍 1
Chris Joslyn 2020-11-16T18:34:46.042600Z

I have an issue where a symbol->symbol map is compiled to a PersistentArrayMap where each keyword appears to be mapped to itself. So when I start with

{:a :b :foo :bar}
the compiler produces
new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.Keyword(null,"b","b",1482224470),new cljs.core.Keyword(null,"foo","foo",1268894036),new cljs.core.Keyword(null,"bar","bar",-1386246584)], null);
Seems like a bug, but I am new to shadow. Version used is 2.11.7.

Clément Ronzon 2020-11-16T18:50:39.044500Z

Hi guys, I read that one can define a custom :ns-runner for the :browser-test target (https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test). I tried to make my own but it didn't work:

Uncaught TypeError: Cannot read property 'init' of undefined
    at (index):2
My custom runner is a copy of shadow.test.browser and I located it in my test directory. Please can someone help me making this work?

dpsutton 2020-11-16T18:59:12.045400Z

What are you expecting to see? Your bug report seems to include a lot of extra stuff

Chris Joslyn 2020-11-16T19:02:48.045600Z

Might be better to describe it this way: a get passing this map and one of the keys produces null. One moment. I can clarify with some specific examples.

dpsutton 2020-11-16T19:04:59.045800Z

yeah just a simple code example would work

Chris Joslyn 2020-11-16T19:06:12.046Z

Source:

(ns shadow-compile-map.core)

(def ^:private example-map
  {:a :b
   :foo :bar})

(defn demo [k]
  (get example-map k))
Main output:
import "./cljs_env.js";
goog.provide('shadow_compile_map.core');
shadow_compile_map.core.example_map = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.Keyword(null,"b","b",1482224470),new cljs.core.Keyword(null,"foo","foo",1268894036),new cljs.core.Keyword(null,"bar","bar",-1386246584)], null);
shadow_compile_map.core.demo = (function shadow_compile_map$core$demo(k){
return cljs.core.get.cljs$core$IFn$_invoke$arity$2(shadow_compile_map.core.example_map,k);
});
I happened to be testing the output in browser, so I have this index.html:
<script type="module">
  import { demo } from "./compiled/demo.js";
  const result = demo("foo");
  console.assert("bar" === result, "The result is %s", result);
</script>

Chris Joslyn 2020-11-16T19:06:33.046200Z

Instead of “bar” I get null .

dpsutton 2020-11-16T19:06:58.046600Z

you're calling demo on the string "foo" which is not in your map

dpsutton 2020-11-16T19:12:20.046800Z

(= :foo "foo") will be false

Chris Joslyn 2020-11-16T19:14:00.047Z

Copy. I had some bad assumptions about interop re: a different part of the app where this came up. It’s not you. It’s me. Thank you.

Clément Ronzon 2020-11-16T19:41:48.047300Z

I think I got it. The file test-dir "index.html" already existed and contained the call to the previous init (`shadow.test.browser`). I deleted it and recompiled. This is now ok. Too bad this file is not cleaned up on a config change.