This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-29
Channels
- # aleph (4)
- # architecture (12)
- # bangalore-clj (1)
- # beginners (87)
- # boot (3)
- # cider (19)
- # cljs-dev (84)
- # clojars (10)
- # clojure (79)
- # clojure-italy (7)
- # clojure-nl (19)
- # clojure-russia (10)
- # clojure-spec (9)
- # clojure-uk (55)
- # clojurescript (64)
- # core-async (7)
- # core-typed (4)
- # cursive (7)
- # data-science (2)
- # datomic (8)
- # devcards (6)
- # docs (1)
- # duct (5)
- # fulcro (117)
- # graphql (1)
- # instaparse (1)
- # leiningen (13)
- # lumo (103)
- # nyc (3)
- # off-topic (54)
- # om (9)
- # onyx (1)
- # pedestal (6)
- # planck (3)
- # portkey (7)
- # re-frame (26)
- # reagent (20)
- # ring-swagger (14)
- # shadow-cljs (164)
- # sql (11)
- # tools-deps (25)
- # yada (1)
Has anyone noticed an error when releasing for :browser with cljs.spec.alpha
? We've just started to see and error with the compiled modules with:
- shadow-cljs 2.3.30
- clojurescript 1.10.238
- node 10.2.1
Uncaught TypeError: L.l is not a function
at dist/cljs/spec/alpha.cljs:91:19 <- dist/shared.js:513:307
TypeError: L.l is not a function
at $n (dist/cljs/spec/alpha.cljs:91:19 <- dist/shared.js:513:307)
at no (dist/cljs/spec/alpha.cljs:300:33 <- dist/shared.js:519:141)
at dist/io/comp/spec/user_spec.cljc:7:0
The line in question is: (s/def :user/first-name u/non-empty-string-conformer)
, which passes all node, doo and clojure testsgenerally that looks like externs trouble but might just be a spec implementation error
I think I ran into something similar when builing a custom spec with deftype
and not defrecord
(defn- non-empty-string [s]
(if (or (not (string? s))
(string/blank? s))
::s/invalid
(string/trim s)))
(def non-empty-string-conformer (s/conformer non-empty-string))
externs problems are sometimes weird to debug since they can mess with your code in unexpected ways
Thanks. The check
shows we have a few places we can fix up. I'll see if inferring helps shortly
Maybe found another problem now after running check IllegalArgumentException: No matching method found: getGlobalType for class com.google.javascript.rhino.jstype.JSTypeRegistry
IllegalArgumentException: No matching method found: getGlobalType for class com.google.javascript.rhino.jstype.JSTypeRegistry
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:53)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
shadow.build.closure/register-cljs-protocol-properties (closure.clj:387)
shadow.build.closure/register-cljs-protocol-properties (closure.clj:372)
shadow.build.closure/check/fn--13533 (closure.clj:1078)
shadow.build.closure/check (closure.clj:1073)
shadow.build.closure/check (closure.clj:1071)
shadow.build/check (build.clj:371)
try
[org.clojure/clojurescript "1.10.238"
:exclusions
[com.google.javascript/closure-compiler-unshaded]]
Yep, excluding the unshaded fixed the getGlobalType
error. I've got a few warnings that may be the underlying cause (externs related). I'll let you know how I go 🙂
check
may be reporting a few false positives. it is not perfect. happy to help if you have questions
@thheller unfortunately, the issue still remains. I've fixed up all the externs within our source. The only thing left I can think of is the (s/def
is doing something else funky
it can sometimes be tough to debug those issues, might need to open up the debugger and step through the code to find out exactly whats happening
Yeah. It's going to be tricky to do so I think. loading all scripts into the page causes it to hang while it trys to do it's thing. I should be able to debug one script at a time hopefully
the problem is L.l is not a function
which is closure-shortened variable. with :pseudo-names
it will not be that short by rather $something$.$fooBar$
so the changes of that conflicting with something are slim over just .l
conflicting with something
but it would still be worth finding out where the l
is coming from in the first place
Hmm. Maybe. We do have a few npm dependencies that are being being used with Shadow. One of them could be doing something internally.
Yep. We leaflet is used as a sub dependency in a package, as an npm dep. So that might be the culprit.
I might just default :output-wrapper
to true as well. its not currently default when using multiple modules because the build gets slightly larger
Cool. It might be worth adding it to the docs as well. It's not listed as a supported option, but is mentioned above somewhere.
Does anyone know if it’s possible to use the suppress annotations provided by closure compiler? Or if not, any kind of workaround that would allow something like the exclusion of particular files from throwing warnings? https://github.com/google/closure-compiler/wiki/@suppress-annotations
Well my understanding is that it will allow me to do this: > If you cannot easily fix a JsCompiler warning, you can suppress it using the @suppress annotation in the function’s JSDoc block
and what is the full warning? the annotations really only suppress warnings for the function you annotate and that should never be necessary in CLJS
It’s cljs and I’m implementing code-splitting - the warning is triggered by the fact that I need to refer to a function in another namespace that has not been required. If I were to require it in then I believe that the bundles would not be correct. Perhaps this would be better dealt with some other way (by using a macro?)
note that you can only actually call the resolved var after the code has been loaded. otherwise it'll just error out
@thheller Thanks for your help there, it’s now working beautifully 🙂 I’m not sure if I’ve struggled with this because I’m new to Clojure & ClojureScript but I wonder if a slightly fuller example of a code-splitting implementation might be helpful to others? I’ve been following this: https://shadow-cljs.github.io/docs/UsersGuide.html#_loading_code_dynamically
@nick828 unfortunately pretty much all uses for code-splitting and dynamic loading rely pretty heavily on the framework you are using and how your code it structured
;; foo.bar is part of module :foo
(def some-var (resolve 'foo.bar/x))
(-> (loader/load "foo")
(.then (fn []
;; foo.bar is now loaded
(some-var))))
so basically whenever you want to call some-var
you probably need to wrap it in a load
call to ensure it is loaded
@thheller fair point, I guess the resolve call was all I needed to understand in the context of loading modules dynamically. Good point on checking that the module is loaded, I had noticed that from the docs. For what it’s worth I’m using Kee-frame for routing although there are many ways to handle the routing, that said I wasn’t suggesting that the docs had anything more than a very basic example of using resolve
- agnostic of any routing…
I’m not sure I quite understand what you’ve got in mind, there is a demo project linked to from Kee-frame’s readme: https://github.com/ingesolvoll/kee-frame-sample, the routers.cljs for the demo project is here: https://github.com/ingesolvoll/kee-frame-sample/blob/master/src/cljs/kee_frame_sample/routers.cljs
looks like it already pretty heavily abstracts all the routing logic though. might make it harder to adapt it to be aware of splits
The commit message might be helpful to explain that: > Changed API to support different routing libs. Example implementation…
Do you just want a boilerplate for handling routes in Kee-frame so that you can give an example implementation of code-splitting in your docs?
not the docs but this example could be made more useful. https://github.com/shadow-cljs/examples/tree/master/code-split
Ah right! I’m with you now - yeah I’d recommend steering clear of a framework for this, I wonder if a very basic bidi
implementation would be enough - you might need more of your own boilerplate to make it work though
to be clear, I’m not saying that this is absolutely necessary in order to understand how to implement code-splitting using Shadow-cljs - just that the current documentation could be a bit clearer about good practices on resolving namespaces that may not have been loaded at the point where the code is first executed
yeah. it is tricky to do this correctly so the docs should definitely clarify this a lot more
I’d love to see an example of how you have done this correctly 🙂 that would be super useful to me
it might be worth having a look at the way it handles code splitting - I haven’t used it for 6months+ but from memory it was pretty straight-forward to implement
It’ll obviously be rather different from how things are handled in the cljs world but I think a lot of the underlying patterns are quite similar
main problem for me is that I don't use reagent. so I have no idea how you'd write it in reagent
Ok, I might be able to convince my people to allow me spin off a generic repo to provide an example in Reagent/Reframe
(defn async-component [the-module the-var]
(let [loading-ref (r/atom false)]
(-> (fn []
(if loading-ref
[:div "Loading ..."]
(the-var)))
(with-meta
{:component-did-mount
(fn [this]
(-> (loader/load the-module)
(.then #(reset! loading-ref true))))}))))
ah, yeah that is a bit of a pain. These docs are quite good: https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md#form-3-a-class-with-life-cycle-methods
This is similar to my first attempt at it, I’ve now moved to a reframe approach using event handlers (coeffects/effects/interceptors) for loading the module at the right time in the application
alternative when using something like re-frame that has an event handler like :set-current-page
or so
Not sure if you saw my message above: > I’ve now moved to a reframe approach using event handlers (coeffects/effects/interceptors) for loading the module at the right time in the application
From the reading I’ve done on approaching problems with a React vs Reframe mindset, I’ve decided to move away from the stateful component pattern
doesn't matter which approach you use. somewhere you need some state that gets updated when the code is loaded and triggers a re-render
@thheller is this the bhauman library for checking maps you were talking about the other day? https://github.com/bhauman/spell-spec it looks amazing
but yeah I was talking about those kinds of error messages. figwheel has some really good error messages.
is cljss an offshoot of the shadow.css stuff in the wiki
I noticed that it has similar macro names
no. I think we more or less both took styled-components from the react work as inspiration
@thheller do you we could update the manifest.json automatically after changing the manifest.edn?