This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-17
Channels
- # aleph (2)
- # announcements (20)
- # aws (43)
- # aws-lambda (5)
- # babashka (9)
- # beginners (231)
- # calva (4)
- # cider (12)
- # cljdoc (8)
- # cljsrn (3)
- # clojure (47)
- # clojure-europe (5)
- # clojure-nl (4)
- # clojure-spec (41)
- # clojure-uk (47)
- # clojuredesign-podcast (3)
- # clojurescript (20)
- # cryogen (3)
- # cursive (4)
- # data-science (2)
- # datomic (15)
- # emacs (4)
- # fulcro (21)
- # jackdaw (6)
- # jobs (1)
- # joker (13)
- # juxt (8)
- # kaocha (10)
- # malli (7)
- # off-topic (29)
- # pathom (11)
- # re-frame (19)
- # reagent (3)
- # reitit (26)
- # remote-jobs (8)
- # schema (2)
- # shadow-cljs (112)
- # spacemacs (1)
- # tools-deps (49)
- # vim (2)
- # xtdb (7)
Hi. I’m trying to build a project that uses Reagent/re-frame on node.js. Everything seems to work fine so far, but I don’t seem to be able to get a final self-contained bundle. Here’s the relevant part of my project.clj:
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.597"
:exclusions [org.apache.ant/ant]]
[reagent "0.8.1"]
[re-frame "0.10.9"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-doo "0.1.10"]]
:target-path "build/cljs/%s/"
:cljsbuild {
:builds [{:id "dev"
:source-paths ["src/clj"]
:compiler {:output-to "app.js"
:optimizations :advanced
:target :nodejs
:hashbang false
:main myapp.core
:npm-deps {:react "16.9.0"
:react-dom "16.9.0"}
}}]}
The bundle seems to contain both react and react-dom, and it looks like they were just copied over verbatim from their minified bundles. But it still contains require("react")
calls (once in the react-dom code and twice in a long line between the react and the react-dom code). These require
s cannot be resolved by node.js when react is not available as an external file. Any idea on how can I get rid of them?Okay, I just noticed that the :npm-deps
part doesn’t seem to have any effect. If I leave it out the result is exactly the same. Also, the react and react-dom versions in the bundle differ from the ones I specified.
I have:
(deftype FnBodyImpl [body params fixed-arity var-arg? fn-name])
in one namespace and:
(:require [sci.impl.types :as t]
[sci.impl.analyzer])
(:import [sci.impl.analyzer FnBodyImpl])
in another. However, the compiler says:
No such namespace: sci.impl.analyzer.FnBodyImpl, could not locate sci/impl/analyzer/FnBodyImpl.cljs, sci/impl/analyzer/FnBodyImpl.cljc
why are you importing? (maybe my cljs knowledge is poor here, but you would require it in Clojure?)
is it possible to have a macro initialize a CLJ namespace and def a new macro in that namespace?
ah I guess this is a no-brainer since I want to be able to require the macro ns in another ns, which means it needs to be available before evaluating the cljs ns
@alexmiller would I require + refer a deftype when I want to use it as a type hint? :thinking_face:
Ah, yes there, but in what case would you need that?
you shouldn't do that
in records, the fields are accessible via the map api
in types, the fields are private
or maybe the non-mutable ones are public, but you still shouldn't do that
the "opinionated" part of deftype (https://clojure.org/reference/datatypes#_datatypes_and_protocols_are_opinionated) is that "You should always program to protocols or interfaces"
I even took this from your blog. Although it was about defrecords, I figured the same approach would work: https://puredanger.github.io/tech.puredanger.com/2010/06/30/using-records-from-a-different-namespace-in-clojure/
anyway, never mind. I was trying a deftype to see if it did anything for performance (for Clojure, in cljc), but in this case, it didn't matter, so I reverted it to a map again
That blog was from right after records/types came out and some things did change after that