Fork me on GitHub
#shadow-cljs
<
2020-05-28
>
rberger04:05:33

I’m trying to use the npm library video.js The JS docs for video.js (https://docs.videojs.com/tutorial-react.html) for use in react says:

import videojs from 'video.js'
and use it like this:
this.player = videojs(this.videoNode, this.props ...)
I do a require in my cljs file:
(:require
   ["video.js" :as vjs])
and I’ve tried
(:require
   ["video.js" :default videojs])
But in the first case vjs/videojs is undefined as is videojs in the second case. Am I doing something stupid, or is something amiss like having the . in the package name is screwing things up?

rberger05:05:08

I just tried putting the actual js file video.js into my work directory and require it as ["./video.js" :as vjs] and ["./video.js" :default videojs] and its behaving the same so I don’t think it’s because of the period. Its something with video.js is setup? They use videojs both as the. top namespace and as the function that effectively instantiates the instance. I don’t know it that is particularly weird for JS or not… They mention it in their docs on videojs : > The `videojs()` function doubles as the main function for users to create a https://docs.videojs.com/Player.html instance as well as the main library namespace. - https://docs.videojs.com/module-videojs-videojs.html

rberger05:05:44

Hmm, if I put <script src=""></script> in my index.html and remove the requires for video.js and refer to it as js/videojs it works….

thheller06:05:35

@rberger it probably is (:require ["video.js" :as videojs]) and videojs directly, not the vjs/videojs alias you tried before.

rberger06:05:54

@thheller That seems to have been it. Now I just. have to figure out how to actually use this thing. Its showing up in my dom as a video element but not playing my streams. But this isn’t a shadow-cljs problem! Thanks again!

rberger07:05:14

By the way, this really tweaks my mental model of :require and :as I always had assumed the :as value was an arbitrary label/symbol…

thheller07:05:07

yeah its weird but string requires are the exception to the rule of :as being just an alias for alias/foo

Diogo Vasconcelos08:05:33

Hi. I am getting the following error when I try to compile any shadow-cljs target from my project. It used to work, but now it errors and I am not sure what changed. Maybe you can help me out figuring out what is wrong:

shadow-cljs - starting via "clojure"
[:dev] Compiling ...
Execution error (AssertionError) at shadow.build.data/add-source (data.clj:214).
Assert failed: (rc/valid-resource? rc)

Full report at:
/tmp/clojure-1306074555799542362.edn

Diogo Vasconcelos08:05:19

thanks in advance 🙂

thheller08:05:30

hmm not sure. which version is this? in deps.edn?

Diogo Vasconcelos09:05:02

of shadow-cljs? 2.9.10

Diogo Vasconcelos09:05:51

(I was on 2.8.83 and got the same error, updated, got a nicer error message 🙂 but still the same issue)

thheller09:05:25

yeah I'll definitely improve that error message. the assert is useless 😛

thheller09:05:28

I don't have any specific idea why this would fail.

thheller09:05:37

try running shadow-cljs clj-repl and then

thheller09:05:59

(in-ns 'shadow.build.data)
(defn add-source [state {:keys [resource-id resource-name] :as rc}]
  (when-not (rc/valid-resource? rc)
    (throw (ex-info "invalid resource" {:rc rc})))

  (-> state
      (update :sources assoc resource-id rc)
      (add-provides rc)
      (cond->
        resource-name
        (update :name->id assoc resource-name resource-id)
        )))

thheller09:05:10

then (shadow.cljs.devtools.api/compile :dev)

Diogo Vasconcelos09:05:21

shadow.build.data=> (shadow.cljs.devtools.api/compile :dev)
[:dev] Compiling ...
invalid resource
{:rc {:cache-key ["5b0a111dc988bc0136ede52338f0c7cd98f61a45"], :ns-info {:rename-macros nil, :renames {}, :meta {:file "repl.cljs", :line 1, :column 5, :end-line 1, :end-column 9}, :use-macros nil, :excludes #{}, :name repl, :imports nil, :requires {cljs-bean.core cljs-bean.core, cljs.pprint cljs.pprint, pprint cljs.pprint, promesa.core promesa.core, p promesa.core, cljs.core cljs.core, goog goog}, :seen #{:require}, :uses {->clj cljs-bean.core}, :require-macros {cljs.core cljs.core}, :cljc false, :flags {:require #{}}, :js-deps {}, :deps [goog cljs.core cljs-bean.core cljs.pprint promesa.core]}, :ns repl, :output-name "repl.js", :file #object[java.io.File 0x32a1aabf "/home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs"], :resource-id [:shadow.build.classpath/resource "repl.cljs"], :resource-name "repl.cljs", :type :cljs, :last-modified -3600000, :requires #{cljs-bean.core promesa.core cljs.core goog cljs.pprint}, :macro-requires #{cljs.core}, :url #object[java.net.URL 0x6b7f46f6 "file:/home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs"], :provides #{repl}, :deps [goog cljs.core cljs-bean.core cljs.pprint promesa.core]}}
ExceptionInfo: invalid resource
	shadow.build.data/add-source (NO_SOURCE_FILE:14)
	shadow.build.data/add-source (NO_SOURCE_FILE:12)
	shadow.build.data/maybe-add-source (data.clj:267)
	shadow.build.data/maybe-add-source (data.clj:259)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:550)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:510)
	shadow.build.resolve/resolve-require (resolve.clj:561)
	shadow.build.resolve/resolve-require (resolve.clj:557)
	shadow.build.resolve/resolve-entry (resolve.clj:571)
	shadow.build.resolve/resolve-entry (resolve.clj:570)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-entries (resolve.clj:582)
	shadow.build.resolve/resolve-entries (resolve.clj:573)
	shadow.build.modules/resolve-module/fn--14145 (modules.clj:265)
	shadow.build.modules/resolve-module (modules.clj:261)
	shadow.build.modules/resolve-module (modules.clj:251)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.build.modules/resolve-modules (modules.clj:271)
	shadow.build.modules/resolve-modules (modules.clj:270)
	shadow.build.modules/analyze (modules.clj:325)
	shadow.build.modules/analyze (modules.clj:316)
	shadow.build/resolve (build.clj:395)
	shadow.build/resolve (build.clj:389)
	shadow.build/compile (build.clj:403)
	shadow.build/compile (build.clj:397)
	shadow.cljs.devtools.api/compile* (api.clj:315)
	shadow.cljs.devtools.api/compile* (api.clj:311)
	shadow.cljs.devtools.api/compile!/body-fn--17311--auto----17398 (api.clj:324)
	shadow.cljs.devtools.api/compile! (api.clj:322)
	shadow.cljs.devtools.api/compile! (api.clj:319)
	shadow.cljs.devtools.api/compile (api.clj:331)
	shadow.cljs.devtools.api/compile (api.clj:326)
	shadow.cljs.devtools.api/compile (api.clj:328)
	shadow.cljs.devtools.api/compile (api.clj:326)
	shadow.build.data/eval38637 (NO_SOURCE_FILE:22)
	shadow.build.data/eval38637 (NO_SOURCE_FILE:22)
	clojure.lang.Compiler.eval (Compiler.java:7177)
	clojure.lang.Compiler.eval (Compiler.java:7132)
	clojure.core/eval (core.clj:3214)
	clojure.core/eval (core.clj:3210)
	shadow.cljs.devtools.server.socket-repl/repl/fn--17818 (socket_repl.clj:63)
	clojure.main/repl/read-eval-print--9086/fn--9089 (main.clj:437)
	clojure.main/repl/read-eval-print--9086 (main.clj:437)
	clojure.main/repl/fn--9095 (main.clj:458)
	clojure.main/repl (main.clj:458)
	clojure.main/repl (main.clj:368)
	shadow.cljs.devtools.server.socket-repl/repl (socket_repl.clj:30)
	shadow.cljs.devtools.server.socket-repl/repl (socket_repl.clj:28)
	shadow.cljs.devtools.server/from-cli (server.clj:678)
	shadow.cljs.devtools.server/from-cli (server.clj:589)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:23)
	shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:20)
	shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:129)
	shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:669)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:665)
	clojure.main/main-opt (main.clj:514)
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)

-3600000 - failed: nat-int? in: [:last-modified] at: [:last-modified] spec: :shadow.build.resource/last-modified
:error

Diogo Vasconcelos09:05:19

thanks for looking into this so quickly btw 🙂

thheller09:05:57

can you check stat /home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs or so?

thheller09:05:08

I have no idea how it gets a negative timestamp?

Diogo Vasconcelos09:05:00

yeah, something is screwed with the modify date on that file:

File: /home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs
  Size: 596       	Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d	Inode: 9570063     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1001/diogovasconcelos)   Gid: ( 1001/diogovasconcelos)
Access: 2020-05-28 10:43:16.172569415 +0200
Modify: 1970-01-01 00:00:00.000000000 +0100
Change: 2020-05-20 14:58:43.953551480 +0200
 Birth: 2020-02-21 10:50:27.964589751 +0100

thheller09:05:20

Modify: 1970-01-01 00:00:00.000000000 +0100?

thheller09:05:29

is this running in a container or so?

thheller09:05:50

maybe just try to touch the file to get an updated timestamp?

Diogo Vasconcelos09:05:19

and I updated it and now the dates are correct. It still fails. I am going to check if other files got this problem and let you know

Diogo Vasconcelos09:05:34

yeah. all the files had the dates screwed (and I think you are right, I did mess with docker and mounting this folder). It works now (I re-cloned the repo)

Diogo Vasconcelos09:05:43

sorry for the trouble

thheller09:05:08

thats weird. how does a file get a negative last-modified timestamp?

thheller09:05:18

:last-modified -3600000

thheller09:05:35

I didn't even know that was possible 😛

😅 4
Ian Fernandez11:05:56

Hello guys, How can I use the "shadow.user" ns that emacs initiates using npx shadow-cljs but starting from cider?

Ian Fernandez11:05:23

I'm having some trouble using cider to start a repl and simply using: (ns user (:require [shadow.cljs.devtools.api :as shadow.api] [shadow.cljs.devtools.server :as shadow.server])) (defn -main {:shadow/requires-server true} [& _] (shadow.server/start!) (shadow.api/watch :my-project))

Ian Fernandez11:05:51

when I use, (shadow.api/rep :my-project)

Ian Fernandez11:05:14

I don't have a repl on cider's repl, I have a repl on stdin on emacs

thheller11:05:05

@d.ian.b if you get a stdin REPL you are not connecting to the shadow-cljs nrepl server

Ian Fernandez11:05:48

yeah, there's a way to start to shadow-cljs nrepl from clj with cider?

thheller11:05:44

I don't know enough about cider to answer that

thheller11:05:56

but if you connect to the nrepl provided by it you can just configure the shadow-cljs middleware

thheller11:05:02

then the repl should also just work

Ian Fernandez11:05:10

there's a way to use this on clj tools.deps?

thheller11:05:47

cider defaults to using .nrepl.edn or so I think. ask in #cider about how to configure middleware

clj 4
thheller18:05:18

I don't use cider so I have no clue how current the instructions here are https://shadow-cljs.github.io/docs/UsersGuide.html#cider

thheller18:05:26

thats all I can link you to unfortunately

thheller14:05:40

I should have known ... never change a running system ... :face_vomiting:

kanwei15:05:41

I'm getting this on 2.9.10

kanwei15:05:43

[:ddplugin] Configuring build.
[:ddplugin] Compiling ...
[:ddplugin] Build failure:
no output for id: [:shadow.build.classpath/resource "goog/base.js"]
{:resource-id [:shadow.build.classpath/resource "goog/base.js"]}
ExceptionInfo: no output for id: [:shadow.build.classpath/resource "goog/base.js"]
	shadow.build.data/get-output! (data.clj:196)
	shadow.build.data/get-output! (data.clj:192)
	shadow.build/enhance-warnings (build.clj:26)
	shadow.build/enhance-warnings (build.clj:22)
	shadow.build/extract-build-info/fn--53837 (build.clj:97)
	clojure.core/map/fn--5866 (core.clj:2753)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.RT.seq (RT.java:535)
	clojure.core/seq--5402 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/reduce (core.clj:6828)
	clojure.core/into (core.clj:6895)
	clojure.core/into (core.clj:6887)
	shadow.build/extract-build-info (build.clj:99)
	shadow.build/extract-build-info (build.clj:69)
	shadow.build/update-build-info-after-compile (build.clj:107)
	shadow.build/update-build-info-after-compile (build.clj:105)
	shadow.build/compile (build.clj:407)
	shadow.build/compile (build.clj:397)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:345)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:327)
	shadow.cljs.devtools.server.worker.impl/eval55641/fn--55643 (impl.clj:779)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--55247/fn--55248/fn--55256 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--55247/fn--55248 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--55247 (util.clj:257)
	java.lang.Thread.run (Thread.java:830)

kanwei15:05:54

only happens when there's already a cached version

thheller16:05:56

hmm strange

thheller16:05:44

just shadow-cljs watch ddplugin and fails immediately?

fabrao18:05:54

Hello all, for this message:

The thheller/shadow-cljs dependency in shadow-cljs.edn was ignored.
can´t I use dependency anymore?

fabrao18:05:58

sorry, I think I asked a dumb question

thheller18:05:34

shadow-cljs knows that you are gonna use shadow-cljs. you don't need to declare it in shadow-cljs.edn.