shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Nolan 2021-02-05T00:10:34.403700Z

ah, impeccable what a few minute break and a glass of water will do. this works as expected:

(shadow/compile
 :build1
 {:config-merge
  [{:closure-defines '{<http://my.app/SOMETHING|my.app/SOMETHING> true}}]})
which makes sense in hindsight. apologies for the noise!

Stevy B 2021-02-05T04:36:42.406200Z

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 <http://localhost:6500>
shadow-cljs - server version: 2.11.4 running at <http://localhost:3449>
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.

thheller 2021-02-05T09:41:51.408700Z

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

Stevy B 2021-02-05T09:45:07.409500Z

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

Stevy B 2021-02-05T09:45:10.409700Z

now all good thanks !

2021-02-05T08:22:44.406700Z

moment-mini

2021-02-05T08:23:47.407500Z

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

2021-02-05T08:24:46.408500Z

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

thheller 2021-02-05T09:44:46.409400Z

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

2021-02-05T10:56:55.410700Z

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'

2021-02-05T10:57:39.411300Z

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

2021-02-05T10:59:33.412700Z

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

thheller 2021-02-05T11:00:12.413300Z

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

2021-02-05T11:01:55.413600Z

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.

2021-02-05T11:02:48.414600Z

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

thheller 2021-02-05T14:54:32.415600Z

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

2021-02-05T14:57:58.417400Z

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

thheller 2021-02-05T14:59:49.418100Z

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 .;?

thheller 2021-02-05T15:00:02.418500Z

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

2021-02-05T15:37:36.420500Z

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

thheller 2021-02-05T15:38:49.421200Z

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

2021-02-05T15:40:04.422300Z

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

thheller 2021-02-05T15:40:43.422600Z

trying to think of a good way to debug this

thheller 2021-02-05T15:44:04.423400Z

@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}]
  
  (-&gt;&gt; output
       (filter #(contains? (:properties %) ""))
       (map :resource-id)
       (prn))
  
  build-state)

thheller 2021-02-05T15:44:18.423800Z

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

thheller 2021-02-05T15:44:36.424300Z

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

2021-02-05T15:44:43.424500Z

ok,let my try

thheller 2021-02-05T15:44:57.424700Z

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

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

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

  build-state)

thheller 2021-02-05T15:46:09.425200Z

you can define it entirely in the REPL too

thheller 2021-02-05T15:46:33.425800Z

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

thheller 2021-02-05T15:49:44.426400Z

oh wait. its missing a (vals)

thheller 2021-02-05T15:49:50.426700Z

(vals output)

thheller 2021-02-05T15:49:56.427Z

forgot its a map 😉

2021-02-05T15:50:22.427600Z

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

2021-02-05T15:51:01.428100Z

oeps, missed some messages

thheller 2021-02-05T15:51:11.428300Z

updated the code snippet

thheller 2021-02-05T15:52:35.428800Z

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

2021-02-05T15:53:07.429Z

Same output with vals

thheller 2021-02-05T15:55:37.429200Z

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 (&lt; (count prop) 2)]
    (prn [:prop resource-id prop]))

  build-state)

thheller 2021-02-05T15:56:05.429500Z

that should at least log something. maybe too much though

2021-02-05T15:57:15.429700Z

got

thheller 2021-02-05T15:58:00.430500Z

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

2021-02-05T15:59:31.431100Z

[: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"]

thheller 2021-02-05T15:59:45.431500Z

yeah those are all fine

2021-02-05T15:59:47.431600Z

[: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"]

thheller 2021-02-05T15:59:55.431900Z

don't need those

2021-02-05T15:59:56.432Z

[: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"]

2021-02-05T16:00:05.432300Z

nothing empty

thheller 2021-02-05T16:00:27.432500Z

yeah those are all fine

thheller 2021-02-05T16:05:57.432700Z

maybe

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

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

  build-state)

thheller 2021-02-05T16:06:16.433200Z

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

2021-02-05T16:20:30.435100Z

[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

2021-02-05T16:20:32.435300Z

YEP

thheller 2021-02-05T16:20:52.435600Z

ah ok, let me get the function to find it

thheller 2021-02-05T16:22:42.435800Z

(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)

thheller 2021-02-05T16:22:44.436100Z

this should do it

thheller 2021-02-05T16:24:52.436600Z

oh oops delete something

2021-02-05T16:24:54.436700Z

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}

thheller 2021-02-05T16:25:35.436900Z

(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)

dpsutton 2021-02-05T16:25:57.437200Z

should state and build-state be the same var?

thheller 2021-02-05T16:26:12.437400Z

oh indeed

thheller 2021-02-05T16:26:20.437600Z

(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)

2021-02-05T16:28:26.437800Z

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

2021-02-05T16:28:46.438100Z

Looks like my code

thheller 2021-02-05T16:31:19.438500Z

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

2021-02-05T16:31:44.439Z

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))))})

thheller 2021-02-05T16:32:06.439300Z

its the entire ns, not the function

thheller 2021-02-05T16:32:26.439600Z

none of the would generate any externs

2021-02-05T16:32:57.440Z

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

2021-02-05T16:33:02.440200Z

i still get the error

thheller 2021-02-05T16:33:26.440400Z

this is the ns glas-editor.plugin-paste

thheller 2021-02-05T16:33:34.440600Z

whatever else is in that file matters

2021-02-05T16:36:58.441300Z

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

2021-02-05T16:38:43.441900Z

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

thheller 2021-02-05T16:38:56.442200Z

thats just a warning, you can ignore that

thheller 2021-02-05T16:39:13.442500Z

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

2021-02-05T16:40:07.442900Z

It did generate a main.js

2021-02-05T16:41:01.443900Z

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

thheller 2021-02-05T16:41:36.444100Z

sure

2021-02-05T16:56:19.445500Z

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/-&gt;js {"headingStyle" "atx"  
 "codeBlockStyle" "fenced"})))

td/. is the cause.

thheller 2021-02-05T17:04:28.445800Z

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

thheller 2021-02-05T17:23:53.446200Z

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

2021-02-05T17:25:14.446500Z

indeed

2021-02-05T17:26:50.447300Z

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

thheller 2021-02-05T17:33:58.447600Z

this is not an error. it is a warning.

thheller 2021-02-05T17:34:36.448200Z

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

jaime 2021-02-05T20:44:38.452100Z

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-&gt; (render (r/as-element [ui/button {:title "My Title"}])) $view
    (.getByText $view "My Title")))

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

thheller 2021-02-05T21:00:24.453300Z

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?

jaime 2021-02-05T21:05:55.455800Z

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

thheller 2021-02-05T21:07:43.456700Z

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

thheller 2021-02-05T21:11:35.457200Z

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

jaime 2021-02-05T21:13:44.458600Z

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)

thheller 2021-02-05T21:14:17.459Z

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

jaime 2021-02-05T21:17:50.460800Z

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

jaime 2021-02-05T21:18:25.461200Z

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

thheller 2021-02-05T21:19:38.461600Z

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

thheller 2021-02-05T21:20:31.462300Z

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

thheller 2021-02-05T21:20:48.462800Z

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

thheller 2021-02-05T21:21:08.463200Z

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

thheller 2021-02-05T21:21:35.463800Z

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

jaime 2021-02-05T21:27:20.464600Z

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

thheller 2021-02-05T21:37:48.465100Z

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

jaime 2021-02-05T21:41:35.466600Z

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