Fork me on GitHub
#cljs-dev
<
2017-10-05
>
juhoteperi17:10:12

The UMD wrapper PR was finally merged into Closure

juhoteperi17:10:55

That should fix least Leaflet & few others, not sure about d3

juhoteperi17:10:24

Yeah, checked d3-array.js and looks like latest Closure-compiler can process that

juhoteperi17:10:45

Hopefully other d3 files use the same wrapper 馃檪

juhoteperi17:10:14

Might already work with Cljs when using Closure snapshot, unless there are some breaking changes on Closure API

thheller17:10:38

maybe someone with self-host experience has a tip for me

thheller17:10:13

I鈥檓 trying to cljs.js/eval-str with a for macro (or any macro) but get a bunch of warnings, eg. WARNING: Use of undeclared Var cljs.core$macros/seq at line 2

thheller17:10:48

I鈥檓 either not setting something I鈥檓 supposed to set

thheller17:10:59

or the analyzer data is incorrect

thheller17:10:10

not sure what could cause this

thheller17:10:59

somehow things in the macro get expanded to cljs.core$macros instead of cljs.core

thheller17:10:31

first time messing with self-host and it just might be because the analyzer data is generated by shadow-cljs

thheller17:10:48

can鈥檛 quite figure it out

anmonteiro18:10:09

@thheller happy to look at a small repro in the stock CLJS REPL

thheller18:10:01

no stack CLJS REPL available since I鈥檓 trying to enable using cljs.js in shadow-cljs builds

thheller18:10:07

I鈥檓 sure the default stuff all works

thheller18:10:48

I鈥檒l figure it out eventually, must just be missing a flag or so

anmonteiro18:10:34

add-core-macros-if-cljs-js?

thheller18:10:07

the macros are generated and loaded

thheller18:10:28

thats all taken care of propery (I think)

thheller18:10:06

but yes, that was the initial problem. macros weren鈥檛 generated at all since I resolve deps a bit differently and don鈥檛 use cljs.closure at all

thheller18:10:34

I can compile code without macros just fine, just the macros don鈥檛 expand quite right

thheller18:10:59

(defn compile-it []
  (cljs/eval-str
    boot/compile-state-ref
    "(ns my.user (:require [reagent.core :as r]))
     (map inc [1 2 3])
     (doall (for [n (range 10)] n))"
    "[test]"
    {:eval cljs/js-eval
     :analyze-deps false
     :verbose true
     :load boot/load}
    print-result))

thheller18:10:16

the for doesn鈥檛 work, everything else is fine

anmonteiro18:10:15

^ you have no other macros in your snippet

thheller18:10:04

yes, other macros fail too

anmonteiro18:10:22

which is why I think you haven鈥檛 loaded the core macros

anmonteiro18:10:30

I would check if (get-in @boot/compile-state-ref [:cljs.analyzer/namespaces 'cljs.core$macros]) is there

anmonteiro18:10:16

what about js/cljs.core$macros in the runtime environment?

anmonteiro18:10:51

cool so there鈥檚 nothing wrong with your compiler state AFAICT

thheller18:10:58

cljs.core$macros.for$ all loaded properly

thheller18:10:56

I don鈥檛 quite get what cljs.js/patch-alias-map does. I never call that so thats my suspect currently.

anmonteiro18:10:53

that will be called for you

anmonteiro18:10:17

the point of that function is making clojure->`cljs` namespace aliasing work

thheller18:10:32

ah ok, that should be unrelated then

thheller18:10:18

(ns demo.macro)

(defmacro foo [& body]
  `(seq ~@body))

thheller18:10:29

Use of undeclared Var demo.macro$macros/seq at line 2

thheller18:10:53

seems like it unquotes incorrectly, can鈥檛 figure out where to control that

thheller18:10:09

ok must be the macro generation. the cljs.core$macros is full of new cljs.core.Symbol("cljs.core$macros","seq","cljs.core$macros/seq",-1873195024,null) which should probably be cljs.core/seq

thheller19:10:29

@anmonteiro I found it. I was reading with the wrong *ns* binding, so cljs.core$macros instead of cljs.core. At least dropping the macros suffix fixed the issue.