Hey guys, when I was doing my project (lein + figwheel-main) converting videos to gif i have a problem after building it into production code, which has an error
Uncaught TypeError: Yo.Zc is not a function
at t.<anonymous> (main_bundle.js:6)
at t.componentDidMount (main_bundle.js:6)
at lo (main_bundle.js:22)
at da (main_bundle.js:22)
at t.unstable_runWithPriority (main_bundle.js:30)
at Bl (main_bundle.js:22)
at ha (main_bundle.js:22)
at Zo (main_bundle.js:22)
at Qo (main_bundle.js:22)
at Ma (main_bundle.js:22)
I guess it's because of the ffmpeg
's functions were also minified, so I had this keyword called externs
, but I don't know how to do it.
Do you guys have any good references to do that?
Thank you ✨I used the code like this
(ns ^:figwheel-hooks video-to-gif.core
(:require
["@ffmpeg/ffmpeg" :refer [createFFmpeg fetchFile]]))
and it's installed using npm install
Hey guys, im getting an error I dont know how to solve. WARNING: contains? already refers to: #'clojure.core/contains? in namespace: clojure-calendar.core, being replaced by: #'java-time/contains? WARNING: iterate already refers to: #'clojure.core/iterate in namespace: clojure-calendar.core, being replaced by: #'java-time/iterate WARNING: range already refers to: #'clojure.core/range in namespace: clojure-calendar.core, being replaced by: #'java-time/range WARNING: min already refers to: #'clojure.core/min in namespace: clojure-calendar.core, being replaced by: #'java-time/min WARNING: format already refers to: #'clojure.core/format in namespace: clojure-calendar.core, being replaced by: #'java-time/format WARNING: zero? already refers to: #'clojure.core/zero? in namespace: clojure-calendar.core, being replaced by: #'java-time/zero? WARNING: max already refers to: #'clojure.core/max in namespace: clojure-calendar.core, being replaced by: #'java-time/max (ns clojure-calendar.core (:gen-class) (:require [cheshire.core :refer :all])) (refer-clojure :exclude [range iterate format max min]) (use 'java-time) Im guessing the solution is in one of the five lines above. Ive tried a couple thing wihtout success. Thanks in advance.
Your require expression is over-writing one of the functions from clojure core.
These errors are one example of why :refer :all
and use
are not recommended and can cause lots of debugging.
If a namespace is predominantly about using a specific library, then
(:require [cheshire.core :refer [function-name another-function etc])
A classic example is a test namespace that uses clojure core
(ns practicalli.random-function-test
(:require [clojure.test :refer [deftest is testing]]
[practicalli.random-function :as sut]))
Otherwise use a meaningful alias, ideally refering to what that library is doing (which makes it easer to swap out with a different library later on if required). As Cheshire is a JSON related library, then
(ns my.ns
(:require [cheshire.core :as json]))
This gives a context to all the functions called from that library and makes code easier for humans to understand.the literal answer here is that contains?
is missing from the refer-clojure additions
but yeah, refer all and use are not typically used
(ns clojure-calendar.core (:gen-class) (:refer-clojure :exclude [range iterate format max min]) (:require [cheshire.core :refer :all] [java-time :refer [local-date plus days]])) Heres what I went with. This gave me no errors when booting and when running the application
Personally I really don't like this code. It seems I've failed to convey why. My apology.
What would you recommend?
the normal thing is to never invoke :refer :all
and to instead use :as
to give the namespace an alias
with :refer
we'd only grab functions that are used very frequently through the namespace
The line (use 'java-time)
is likely the cause of this. use
means that you want all names defined in the specified namespace to NOT require any prefix in order to refer to them in the namespace clojure-calendar.core
, where the use
occurs. Some of those names apparently are the same as names in clojure.core
If you are willing to use a prefix for the names in the java-time
namespace, you can instead do something like this:
(ns clojure-calendar.core
(:gen-class)
(:require [cheshire.core :refer :all]
[java-time :as jt]))
;; Use jt/zero? to refer to the name zero? inside of the namespace
;; java-time, and zero? to refer to the name zero? in clojure.core
If you truly want to use no prefix for the names in namespace java-time
, and you are OK with using clojure.core/zero?
if you want to use the definition of zero?
in clojure.core
, then you could use something like this:
(ns clojure-calendar.core
(:gen-class)
(:refer-clojure :exclude [range iterate format max min])
(:require [cheshire.core :refer :all]
[java-time :refer :all]))
It isn't clear to me why having the code the way you show it is not avoiding these warning messages. They are harmless, but agreed it is good to try to eliminate them, so you do not get used to ignoring warnings.
I tried both solutions. I went with the second solution as I didnt have to change or put jt infront of things. It eliminated most errors. Im still getting these WARNING: contains? already refers to: #'clojure.core/contains? in namespace: clojure-calendar.core, being replaced by: #'java-time/contains? WARNING: zero? already refers to: #'clojure.core/zero? in namespace: clojure-calendar.core, being replaced by: #'java-time/zero? If you think taking a peep at the project will help. https://github.com/SantoHerrera/clojureCalendar
Thanks for the help
I wrote a test for a macro by comparing the macroexpand
result to what i expect - does that make sense?
I think it is a kind of test that is direct and can certainly make sense. Another is to write a test that invokes the macro and tests the behavior of executing the resulting code, of course.
Yeah that one is more tricky - it create a var in the current namespace, so I will have to understand how that works in tesring. But I will give it a shot.
Hmm interesting problem .. I have a macro that calls out to app.util/foo
- when running in production this works because app.util is loaded .. but when I run a unit test, app.util
is not loaded yet and compilation fails.
I can solve this by requiring app.util in my test of course. But, I wonder if that is the correct solution.
What do you do with macros that need to refer to code in different packages. Should the macro somehow load those, or should that be part of the package where the macro is called?
Hey folks! Is there a generic way in Clojure to implement something like the multi-method table, where you can retrieve all defmethod
definitions using methods
? E.g. suppose I write a library with a deffoobar
macro -- I'd like a feature of this library to be that it pulls in all the user's deffoobar
definitions and does something to them
If you mean, is there some provided functions or data structures and conventions that extensions like that are encouraged to use, then I believe the answer is "no".
You can of course examine the existing implementation of those things, and implement something similar yourself.
I may be misunderstanding your original message, but I thought that methods
lets you get all method definitions for a single multimethod that you provide as a parameter. I do not believe anything in Clojure lets you retrieve all names given in defmulti
invocations, for example.
But you did say all defmethod
definitions, not defmulti
definitions, so that is likely what you intended.
Ah good to know, I'll look into implementing something myself but it's great to have clarification :)
And yes - the mechanism by which methods
retrieves definitions for a single multimethod is all I'm after, so your original interpretation was spot on
Appreciate the help!