This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-12
Channels
- # aleph (11)
- # aws-lambda (1)
- # beginners (158)
- # boot (19)
- # cider (14)
- # clara (23)
- # cljs-dev (3)
- # clojars (4)
- # clojure (133)
- # clojure-dev (57)
- # clojure-dusseldorf (1)
- # clojure-finland (2)
- # clojure-gamedev (31)
- # clojure-greece (15)
- # clojure-ireland (1)
- # clojure-italy (3)
- # clojure-russia (8)
- # clojure-spec (149)
- # clojure-uk (51)
- # clojurescript (88)
- # community-development (1)
- # component (5)
- # cursive (17)
- # datomic (3)
- # emacs (6)
- # fulcro (142)
- # graphql (1)
- # juxt (15)
- # lein-figwheel (1)
- # luminus (3)
- # lumo (6)
- # off-topic (11)
- # om (8)
- # onyx (5)
- # portkey (6)
- # proton (2)
- # protorepl (3)
- # quil (6)
- # re-frame (14)
- # reagent (9)
- # shadow-cljs (226)
- # specter (11)
- # testing (96)
- # uncomplicate (5)
- # unrepl (8)
- # vim (11)
(defmacro <>
([el content] (<> &form &env el content nil))
([el content style] `(~el {:inner-text ~content, :style ~style})))
cljs.user=> (ns foo.core$macros)
nil
foo.core$macros=>
foo.core$macros=> (defmacro <>
#_=> ([el content] (<> &form &env el content nil))
#_=> ([el content style] `(~el {:inner-text ~content, :style ~style})))
true
foo.core$macros=> (foo.core/<> 'a "a" nil)
nil
foo.core$macros=> (foo.core/<> 'a "a")
nil
foo.core$macros=> '(foo.core/<> 'a "a")
(foo.core/<> (quote a) "a")
foo.core$macros=> '(foo.core/<> 'a "a" nil)
(foo.core/<> (quote a) "a" nil)
foo.core$macros=> (macroexpand-1'(foo.core/<> 'a "a" nil))
WARNING: Use of undeclared Var foo.core$macros/macroexpand-1' at line 1
TypeError: Cannot read property 'call' of undefined
foo.core$macros=> (macroexpand-1 '(foo.core/<> 'a "a" nil))
((quote a) {:inner-text "a", :style nil})
foo.core$macros=> (macroexpand-1 '(foo.core/<> 'a "a"))
((quote a) {:inner-text "a", :style nil})
just guessing https://github.com/clojure/core.specs.alpha/commit/93f655c297f7a4e9d8fa7cd549ec08660130d925#commitcomment-24248628
@jiyinyiyong shadow-cljs is not self-hosted therefore macros need to be written in Clojure
by the looks of it you are trying to use CLJS code from CLJ, that won’t work without some reader conditionals
.cljc files can be loaded by CLJS and CLJ but when loading CLJ you can’t use CLJS code so you have to use reader conditionals
so if the file that was required then tries to :require-macros
it fails because CLJ is the one loading it and not CLJS
it matters who is loading the .cljc
file. the CLJS compiler where :require-macros
is fine OR Clojure where it is not fine
my file is compiling with shadow-cljs and running in a browser, I can't see where is the .clj
part
if you :require-macros
something that is loaded by clojure. everything macro related is clojure.
Sounds like something I didn't even noticed before. The same code was ok, but I saw compilation errors today.
I mean, the behaviors of the compiler just changed with the same copy of code. no new commits, not deps updates
I would stay away from .cljc files personally, they just make things a lot more complicated
bascially whenever you need a macro you create a .cljs files and a .clj file of the same name
IMHO it is not a good idea to have a respo.macros
namespace, puts too much emphasis on the macro part.
I agree. But I don't have enough experience to decide which solution is best for my case. I still have to deal with the edge cases,
well that you are writing your own editor that has to deal with all the edge cases certainly adds a bit of complexity on top 😉
my current headache is, in the file I write Macros, I need to require code from my ClojureScript code written in .cljs
.
but we need most of the features in Webpack, when we where trying to create single page apps.
yeah, requirejs has a command line called r.js
, which bundles code. But it's using AMD format, which not as useful as CommonJS, so it's barely used now.
well it sort of can do it if I combine DllPlugin
and DllReferencePlugin
but that whole setup is just crazy
maybe, don’t know who to talk to or even how to describe what it is I’m trying to do
I can just wait till Closure supports everything … which will happen eventually (hopefully)
yeah lots of stuff happening with webpack, getting more complicated with every change
I just feel that he is so happy the performance of compiler beat all other compilers of altjs languages.
I personally care very little about the speed of the compiler when my compiled output is a lot smaller and optimized
I think people don't always care about the bundle size that much, for example some of my apps in my previous work, they are used internally. So the size the not important. My manager just want the websites get online really quickly.
well if you don’t care about the size then using webpack with shadow-cljs should just work fine?
yeah, if I can split ClojureScript libraries into another bundle, then it's acceptable in some scenarios.
anyway, the current problem of using ClojureScript in China is just too few people are using it. we would think about size after people start using it.
attempted to write the webpack plugin at least 4 times in the last month and always gave up
I imagined there might be some chance that Webpack maintainers will help ClojureScript, although it's rare.
well by the looks of it all I need is browserify -r react -r react-dom
and then something combined with -x=react
being a user of both tools, I just hope to see ClojureScript works in Webpack, just like TypeScript and BuckleScript. 🙂
the loader part is problematic because clojurescript uses namespaces to organize code
I expect a whole lot more people using the Closure Compiler soon which should make things easier to use in CLJS as well
not found much voices https://twitter.com/search?q=typescript%20closure%20compiler&src=typd
while for webpack, there are much more https://twitter.com/search?q=typescript%20webpack&src=typd
yeah, well only because people talk about it more doesn’t mean that it is “better” 😉
people in JavaScript world rely on documents heavily. I don't think Closure Compiler team is good at documents
yeah agreed. its mostly used by Google internally so I bet they have internal docs just nothing public
(defmacro meta' [props & children] `(create-element :meta ~props [email protected]))
(defn gen-dom-macro [el]
`(defmacro ~el [~'props ~'& ~'children]
`(create-element ~(keyword '~el) ~~'props ~@~'children)))
(ns respo.alias (:require [respo.core :as core]) (:require-macros [respo.alias]))
(def create-element core/create-element)
(def create-comp core/create-comp)
now I put my code back in a file called alias.clj
, but in alias.clj
, I don't get the variables defined in alias.cljs
.
requires some trickery but it seems browserify has solved the issue I was trying to solve for the last month using webpack
I needed a way of packages JS together but still being able to require
the packages by name
ie. want to bundle react
and react-dom
together (or separate) and then still use require
to access them
well if you use webpack you already have something that can provide require("react")
but I wanted a more lightweight way of being able to use require("react")
without using webpack
so if you set :js-provider :closure
the (:require ["react"])
will attempt to import the npm react package via the closure compiler
in the old days, we have gulp-rev
for browserify https://stackoverflow.com/a/33507199/883571
if you set :js-provider :require
it will just emit a require("react")
call, which just works for node.js or when using webpack
first plan was using webpack in the background but that was way harder than I wanted it to be
cool cool, thanks for suggesting browserify. I got further in the last hour than in the last 4 months trying to understand webpack 😛