Fork me on GitHub
#shadow-cljs
<
2020-11-16
>
dehli15:11:59

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)

thheller15:11:48

do you have the build configs you used?

thheller15:11:20

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

dehli16:11:41

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!

dehli16:11:06

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

thheller16:11:10

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

👍 3
thisgeek18:11:46

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.

dpsutton18:11:12

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

thisgeek19:11:48

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.

dpsutton19:11:59

yeah just a simple code example would work

thisgeek19:11:12

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>

thisgeek19:11:33

Instead of “bar” I get null .

dpsutton19:11:58

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

dpsutton19:11:20

(= :foo "foo") will be false

thisgeek19:11:00

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 Ronzon18:11:39

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?

Clément Ronzon19:11:48

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.