Fork me on GitHub
#shadow-cljs
<
2021-02-05
>
Stevy B04:02:42

Hi all ! Beginner here. I am trying to compile my app with

shadow-cljs watch dev-ui
But I am getting this error :
shadow-cljs - config: .../shadow-cljs.edn
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.4 running at 
shadow-cljs - nREPL server started on port 54872
shadow-cljs - watching build :dev-ui
[:dev-ui] Configuring build.
[:dev-ui] Compiling ...
[:dev-ui] Build failure:
The required namespace "react" is not available, it was required by "reagent/core.cljs".
I have installed react with
npm install react react-dom create-react-class 
but the issue is still there. Let me know if I am doing everything right ? Thanks for the help.

thheller09:02:51

did you install it in the correct directory? there should be a <project>/node_modules/react directory. if you don't have a package.json in your project dir it might install somewhere else.

Stevy B09:02:07

I didnt install npm in the right folder that was the issue

Stevy B09:02:10

now all good thanks !

Peter Muys08:02:47

Hello, I have a problem when doint a release with shadow-cljs, I get the following error: [:app] Compiling ... [2021-02-05 09:20:43.012 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]} Closure compilation failed with 1 errors --- externs.shadow.js:13 Parse error. 'identifier' expected

Peter Muys08:02:46

The js-invalid-requires also comes up when watching (shadow-cljs watch app), but everything seems to work fine

thheller09:02:46

@peter085 don't know that package. it might try to do a dynamic import() which is not supported

Peter Muys10:02:55

When looking at the moment.min.js file ate columnn 4095 i see a function with 'return"string"==typeof e?W[e]||W[e.toLowerCase()]:void 0'

Peter Muys10:02:39

When i look at externs.shadow.js:13 i see ShadowJS.prototype.;

Peter Muys10:02:33

the package moment-mini is a dependency of (I think) mermaid npm module.

thheller11:02:12

hmm odd. seems like shadow-cljs collected some kind of empty externs property. no clue how.

Peter Muys11:02:55

The description of moment-mini: This package exposes https://github.com/moment/moment/blob/develop/min/moment.min.js as an npm module so you can import/require the minified version of moment into your projects without the bloat of the locales. This package will follow the https://github.com/moment/moment/releases.

Peter Muys11:02:48

How could I solve this problem? It stops me from deploying my app.

thheller14:02:32

@peter085 I don't know. I tried the moment-mini and mermaid packages and they compile fine. something must confuse the externs generator but I don't know how or what.

Peter Muys14:02:58

Ok, thanks for looking. BTW I otherwise love shadow-cljs (never had a problem like this before)

thheller14:02:49

it is a very odd issue. can you check if the line ShadowJS.prototype.; is actually ShadowJS.prototype.; and not maybe some unicode char or so behind inbetween the .;?

thheller15:02:02

its not supposed to generate empty externs and I don't know how it would

Peter Muys15:02:36

@thheller This is a copy with lines before and after, it doesn't show any other chars. / @const {ShadowJS} */ var location; / @const {ShadowJS} */ var module$node_modules$codemirror$lib$codemirror; ShadowJS.prototype.; ShadowJS.prototype.$; ShadowJS.prototype.$$typeof;

thheller15:02:49

hmm yeah would be interested to find out how it gets to generate an empty externs entry

Peter Muys15:02:04

Do you need any other info, like package.json or something else?

thheller15:02:43

trying to think of a good way to debug this

thheller15:02:04

@peter085 can you create an empty CLJ ns like (ns debug) and put this in it

(defn find-it
  {:shadow.build/stage :flush}
  [{:keys [output] :as build-state}]
  
  (->> output
       (filter #(contains? (:properties %) ""))
       (map :resource-id)
       (prn))
  
  build-state)

thheller15:02:18

then in your build-config set :build-hooks [(debug/find-it)]

thheller15:02:36

that should then at least tell us which of the files is causing the empty externs

Peter Muys15:02:43

ok,let my try

thheller15:02:57

oh wait it doesn't get to flush, use this instead

(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [{:keys [output] :as build-state}]

  (->> (vals output)
       (filter #(contains? (:properties %) ""))
       (map :resource-id)
       (prn))

  build-state)

thheller15:02:09

you can define it entirely in the REPL too

thheller15:02:33

doesn't need to be in a file just shadow-cljs clj-repl is fine

thheller15:02:44

oh wait. its missing a (vals)

thheller15:02:50

(vals output)

thheller15:02:56

forgot its a map 😉

Peter Muys15:02:22

I got the following: shadow-cljs - starting via "clojure" WARNING: When invoking clojure.main, use -M enabling instrumentation [:app] Compiling ... [2021-02-05 16:48:35.711 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]} () Closure compilation failed with 1 errors --- externs.shadow.js:13 Parse error. 'identifier' expected The only difference is the () in de output, 'enabling instrumentations' is something from my code

Peter Muys15:02:01

oeps, missed some messages

thheller15:02:11

updated the code snippet

thheller15:02:35

yeah the () would be the empty sequence from the prn if it didn't find what it was looking for

Peter Muys15:02:07

Same output with vals

thheller15:02:37

maybe try

(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [{:keys [output] :as build-state}]

  (doseq [{:keys [resource-id properties]} (vals output)
          prop properties
          :when (< (count prop) 2)]
    (prn [:prop resource-id prop]))

  build-state)

thheller15:02:05

that should at least log something. maybe too much though

thheller15:02:00

can ignore anything thats not empty, just need to find the one that "looks" empty

Peter Muys15:02:31

[:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "L"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "R"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "C"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "P"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "U"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "N"]
[:prop [:shadow.build.npm/resource "node_modules/d3-shape/dist/d3-shape.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-shape/dist/d3-shape.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/shapes.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/shapes.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "q"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/coordinate-system.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/coordinate-system.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "f"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "y"]

thheller15:02:45

yeah those are all fine

Peter Muys15:02:47

[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-polygon.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-polygon.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-contour/dist/d3-contour.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-contour/dist/d3-contour.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-path/dist/d3-path.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "n"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "z"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "e"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "p"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "t"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "o"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/graph.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/graph.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-ellipse.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-ellipse.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/normalize.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/normalize.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-rect.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-rect.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-dispatch/dist/d3-dispatch.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "d"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "n"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "p"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "t"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "$"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "o"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "c"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/create-edge-paths.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/create-edge-paths.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/grayscale.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "d"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "Q"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "q"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "L"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "p"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "M"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "S"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "Z"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "H"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "V"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "U"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "X"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "u"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "W"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "c"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/util.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/util.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "c"]

thheller15:02:55

don't need those

Peter Muys15:02:56

[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "n"]
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "e"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/order/barycenter.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "k"]
[:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/elm/elm.js"] "f"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/json.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/json.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-line.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-line.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/greedy-fas.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/greedy-fas.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/position/index.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/position/index.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "e"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "d"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "L"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "M"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/haskell/haskell.js"] "f"]
[:prop [:shadow.build.npm/resource "node_modules/d3-quadtree/dist/d3-quadtree.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-quadtree/dist/d3-quadtree.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/order/resolve-conflicts.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "z"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "t"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "A"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "c"]
[:prop [:shadow.build.npm/resource "node_modules/d3-chord/dist/d3-chord.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "c"]

Peter Muys16:02:05

nothing empty

thheller16:02:27

yeah those are all fine

thheller16:02:57

maybe

(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [build-state]

  (prn (shadow.build.closure/extern-props-from-cljs build-state))

  build-state)

thheller16:02:16

if that contains "" then it is somehow coming from CLJS not JS

Peter Muys16:02:30

[2021-02-05 17:19:55.794 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]}
#{"" "_run" "NaN" "flush-after-render" "getMode" "unbounded-unshift" "_peek-at" "_update-watching" "fromCharCode" "onChange" "_queued-run" "add-after-render" "flush-render" "_set-opts" "_peek" "isScrolling" "floorEntry" "autoLoadMode" "ceilingEntry" "createElement" "Fragment" "PersistentVector" "copyState" "POSITIVE_INFINITY" "findModeByName" "Children.toArray" "queue-render" "schedule" "startState" "_set-state" "hasNext" "findDOMNode" "flush-queues" "_handle-change" "getLength" "PersistentArrayMap" "Doc" "render" "_try-capture" "flush-before-flush" "cljsIsDirty" "unmountComponentAtNode" "NEGATIVE_INFINITY" "Component" "add-before-flush" "run-queues" "core" "equiv"}
Closure compilation failed with 1 errors
--- externs.shadow.js:13
Parse error. 'identifier' expected

thheller16:02:52

ah ok, let me get the function to find it

thheller16:02:42

(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [{:keys [ns file] :as src}
          :let [{:shadow/keys [js-access-properties]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])] 
          :when (contains? js-access-properties "")]
    (prn [:found ns js-access-properties]))
  
  build-state)

thheller16:02:44

this should do it

thheller16:02:52

oh oops delete something

Peter Muys16:02:54

something wrong in find-it

[2021-02-05 17:23:40.074 - WARNING] :shadow.build/hook-config-ex - {:hook-idx 0, :hook-sym debug/find-it, :build-id :app}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error macroexpanding doseq at (debug.clj:15:13). #:clojure.error{:phase :macro-syntax-check, :line 15, :column 13, :source "debug.clj", :symbol doseq}

thheller16:02:35

(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [src-id (:build-sources state)
          :let [{:keys [ns file] :as src}
                (get-in state [:sources src-id])
                {:shadow/keys [js-access-properties]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
          :when (contains? js-access-properties "")]
    (prn [:found ns js-access-properties]))

  build-state)

dpsutton16:02:57

should state and build-state be the same var?

thheller16:02:20

(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [src-id (:build-sources state)
          :let [{:keys [ns file] :as src}
                (get-in state [:sources src-id])
                {:shadow/keys [js-access-properties]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
          :when (contains? js-access-properties "")]
    (prn [:found ns js-access-properties]))

  state)

Peter Muys16:02:26

Got [:found glas-editor.plugin-paste #{""}]

Peter Muys16:02:46

Looks like my code

thheller16:02:19

would be curious to see what that does and how ends up adding an empty property

Peter Muys16:02:44

This is the function

(defn plugin-paste []
			{}
			{:on-cm-init (fn [editor config state]
											 (cm/on-paste editor (fn [editor event]
																							 (on-paste-event editor event))))})

thheller16:02:06

its the entire ns, not the function

thheller16:02:26

none of the would generate any externs

Peter Muys16:02:57

if i change it to 
(defn plugin-paste []
			{})

Peter Muys16:02:02

i still get the error

thheller16:02:26

this is the ns glas-editor.plugin-paste

thheller16:02:34

whatever else is in that file matters

Peter Muys16:02:58

I removed the require for the  plugin name space, now i get
[:app] Compiling ... [2021-02-05 17:35:32.949 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]} ------ WARNING #1 - ----------------------------------------------------------- Resource: node_modules/codemirror/lib/codemirror.js:2 constant module$node_modules$codemirror$lib$codemirror assigned a value more than once. Original definition at externs.shadow.js:11 --------------------------------------------------------------------------------

Peter Muys16:02:43

externs.shadow.js:
/** @const {ShadowJS} */ var location;
/** @const {ShadowJS} */ var module$node_modules$codemirror$lib$codemirror;   <-- ln 11
ShadowJS.prototype.$;
ShadowJS.prototype.$$typeof;

thheller16:02:56

thats just a warning, you can ignore that

thheller16:02:13

dunno how that happens either but for now it doesn't matter

Peter Muys16:02:07

It did generate a main.js

Peter Muys16:02:01

Ok, I will try removing code bit by bit in glas-editor and let you know what i found. Ok for you?

Peter Muys16:02:19

Found the following code that generates the error:

(ns glas-editor.plugin-paste  
  (:require 
  ...
  \["turndown" :as td\]  
 \["turndown-plugin-gfm" :as tdgfm\]  
 ))
 
 (def td-service (td/. (bean/->js {"headingStyle" "atx"  
 "codeBlockStyle" "fenced"})))

td/. is the cause.

thheller17:02:28

how does that even work? thats not a valid JS function name?

thheller17:02:53

@peter085 is that supposed to be (td. ...) without the /?

Peter Muys17:02:50

Doesn't explain the moment-mini error, but does explain the externs problem i think

thheller17:02:58

this is not an error. it is a warning.

thheller17:02:36

just search for require in the code. anything that is not just a plain require call with a string argument is "invalid"

jaime20:02:38

Hi, I'm trying to run-tests using @testing-library/react-native npm module. But I'm getting this error

undefined is not an object (evaluating 'shadow.js.shim.module$$testing_library$react_native.render')
Here is my test file (I think I'm importing it correct, see the js example https://callstack.github.io/react-native-testing-library/docs/getting-started/#example)
(ns limeray.component-test
  (:require [clojure.test :refer [deftest run-tests run-all-tests]]
            ["@testing-library/react-native" :refer [render]]
            [reagent.core :as r]
            [limeray.component :as ui]))

(def jaime (render (r/as-element [ui/button {:title "My Title"}])))

(deftest render-button-with-title
  (as-> (render (r/as-element [ui/button {:title "My Title"}])) $view
    (.getByText $view "My Title")))

(run-tests)
Is this something related to externs?

thheller21:02:24

no. there just doesn't seem to be a render function. looks correct otherwise but I don't know the setup. is this running in node or how does it work?

jaime21:02:55

:thinking_face: I'm running shadow-cljs watch app , then using cursive I connected to the repl, then switched to cljs by calling (shadow.cljs.devtools.api/repl :app) The connected client is an android emulator. What I'm doing is to send the run-tests in repl.

thheller21:02:43

yeah that doesn't work. you cannot add requires dynamically in a react-native env. so if you regular app doesn't have this require then adding it via the REPL won't work

thheller21:02:35

but I really don't know anything about how react-native testing works or what kind of setup it requires

jaime21:02:44

Oh ok. Maybe I can try testing it in node-repl and see if it will work. Looking at the library, it is just a wrapper for react-test-renderer which I think deals only with js objects (vdom)

thheller21:02:17

that won't work if your code requires react-native anywhere. since that package needs to be built by metro

jaime21:02:50

I see. looks like I have to do some research how testing works in react-native. Thanks a lot for clarifying. Btw, out of curiosity, you cannot add requires dynamically in a react-native env. In the context of browser env, what does it mean by requiring dynamically? Maybe this will help me understand why its not possible in react-native

jaime21:02:25

Or I would say, what is happening when doing require dynamically.

thheller21:02:38

dynamically as in anything done in the REPL and not at build-time

thheller21:02:31

shadow-cljs just generates some JS for your build but does not provide any JS dependencies

thheller21:02:48

metro will then process that generated JS and actually fill in those dependencies such as react-native itself

thheller21:02:08

this output you then load and all requires that were provided are available

thheller21:02:35

however if you now connect the REPL metro is out of the equation and as such cannot provide JS dependencies anymore

jaime21:02:20

Does that mean if I require lets say the @testing-library/react-native in my production code. Metro will be able to provide it as deps? EDIT: I've just tried it, looks like lib is now being loaded

thheller21:02:48

yes, if you get it into the build somehow it'll be available

jaime21:02:35

Cool. I think I can do this a temp fix for now. Thanks a lot. appreciate your help and explaining in detail 😄