Hello! We're using babel to compile some portions of our code with typescript and tsx. Essentially we're doing https://www.youtube.com/watch?v=Bp2d0jQx8Gs, with a bit of config on the side:
"start": "npx shadow-cljs watch dev & npm run babel -- --watch",
The babel output gets put into a directory src/gen/ that we can require into our namespace eg ["/components/IconButton" :refer [IconButton]]
The question:
Babel outputs source maps but shadow-cljs either doesn't see them or doesn't pass them through it's build. Does anyone know if I can get shadow-cljs to consume the source maps from the babel output or if there is a better way of doing this part of the build?that entire code path is a bit sketchy and I no longer recommend using it. instead output all your babel output to packages/some-name and then consume it via (:require ["some-name/components/IconButton" ...])
then in your build config set :js-options {:js-package-dirs ["packages" "node_modules"]}
this effectively treats your babel output as its own npm package, found via the packages dir
input source maps are however still a bit of an issue and unlikely to work properly there too
Ok thank you, appreciate the response!
Should I expect clojure.edn/read-string to pull in numbers as #object[Number] as opposed to #number ? In release mode I was seeing some problems with these not being used as a plain number. I had to go to efforts to cause the proper conversion.
what behavior are you seeing?
❯ clj -A:cljs -m cljs.main -re node -r
WARNING: Implicit use of clojure.main with options is deprecated, use -M
ClojureScript 1.10.773
cljs.user=> (type 3)
#object[Number]
cljs.user=> (clj->js 3)
3
cljs.user=> (type *1)
#object[Number]
cljs.user=> (require 'clojure.edn)
nil
cljs.user=> (clojure.edn/read-string "3")
3
cljs.user=> (type *1)
#object[Number]works as expected in non-release mode. In release mode, there is an extra call on a method that returns nil. So I see sat = l.xd() if I set a break point, I can see that l is #object[Number] but that the method .xd() returns nil. might not be exactly 'xd'...doing this from memory. It took me a bit to get it to work, and I don't precisely know why I ran into this.