Problem with including JSX in Clojurescript build as a foreign library

190 views
Skip to first unread message

Timur

unread,
Dec 12, 2015, 9:04:50 AM12/12/15
to ClojureScript
Hi all,

I'm trying to set-up my clojurescript build that's using a js lib with JSX definitions. But this ends up with the following error:

SyntaxError: expected expression, got '<'

<div className="commentBox">

This error is thrown for the compiled/out/components.js

My includes in the HTML are as follows:

<script src="js/compiled/out/react.inc.js"></script>
<script src="js/compiled/out/react-dom.inc.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"> </script>

Apart from that my clojure build is:

{:main uni-stuttgart.ipsm.coact.core
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:asset-path "js/compiled/out"
:foreign-libs [{:file "resources/public/js/libs/components.js"
:provides ["libs.components"]
:preprocess :jsx}]
:source-map-timestamp true
}

And the components.js is:

/**
* @jsx React.DOM
*/
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
);
}
});


Any ideas how to fix this problem?

Regards,

Timur

Mike Fikes

unread,
Dec 12, 2015, 11:02:01 PM12/12/15
to ClojureScript
Hi Timur,

Have you set up a defmethod js-transforms for :jsx (the value specified in :preprocess)?

- Mike

Timur Sungur

unread,
Dec 13, 2015, 1:57:42 PM12/13/15
to ClojureScript

Hi Mike,

Thanks for the answer.

Nope, is there any documentation about how I integrate it into my cljs build? I saw this one [1], but it requires a separate build setting and execution, I would preferably avoid that.

[1] https://github.com/mneise/circle-color/blob/master/scripts/build.clj

Regards,

Timur


--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/idilFfxaUW0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

mikef...@gmail.com

unread,
Dec 13, 2015, 5:41:29 PM12/13/15
to clojur...@googlegroups.com
There's no docs that I'm aware of beyond documenting the general hook in the Compiler Options wiki.

The main requirement is to supply a defmethod—I don't know how that is done with lein cljsbuild or Boot.

FWIW, Maria wrote the compiler feature and also maintains cljsbuild.

- Mike
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.

Maria Geller

unread,
Dec 13, 2015, 9:18:17 PM12/13/15
to ClojureScript
Hi Timur,

Mike is right, there is no documentation for this compiler option that I'm aware of other than my blog post (http://mneise.github.io/posts/2015-08-04-week-9-and-10.html) and the small example repo you already found.

Unfortunately, this feature is not yet supported by lein-cljsbuild. Need to think a bit about what the best way is to support it in lein-cljsbuild, but PRs are always welcome ;)
Reply all
Reply to author
Forward
0 new messages