[ClojureScript] Re: Simple es6 JS file fails to compile as foreign lib
The Closure Compiler is fully capable of this. It appears that something is broken, don't know what. In shadow-cljs [1] I handle JS dependencies quite differently so not only does this work there it is also much simpler (IMHO). I made a demo showcasing all of the JS interop here: https://github.com/thheller/shadow-cljs-examples/tree/master/local-js You can clone it and run: npm install npx shadow-cljs watch app open http://localhost:9300 These two files are interesting: https://github.com/thheller/shadow-cljs-examples/blob/master/local-js/src/demo/app.cljs https://github.com/thheller/shadow-cljs-examples/blob/master/local-js/src/demo/foo.js The CLJS files is using JS and the JS file is using CLJS. 100% full interop. Note that the use of :default in the ns :require is not yet official [2]. The support for relative require (ie. "./foo") was rejected and is "never, ever going to happen." [3]. I consider this an experiment to explore alternatives to :foreign-libs as I think they are deeply flawed and should be abandoned. It works well in shadow-cljs but please don't use it in any library until there is something "official" to make all of this work. Cheers, /thomas [1] https://github.com/thheller/shadow-cljs [2] https://dev.clojure.org/jira/browse/CLJS-2376 [3] https://dev.clojure.org/jira/browse/CLJS-2061?focusedCommentId=46191&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-46191 -- Note that posts from new members are moderated - please be patient with your first post. --- 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 clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at https://groups.google.com/group/clojurescript.
[ClojureScript] Re: Simple es6 JS file fails to compile as foreign lib
Thomas, thanks for the detailed example! I was reading over the weekend about shadow-cljs and it is definitely an intriguing approach. However, my motivation for these es6 experiments is to eventually bring them into a larger project I am working on, which already has an existing boot build framework. Realistically, I'm probably going to have to make it work within the boot ecosystem. I'm curious why you think :foreign-libs is deeply flawed. It is my understanding that :npm-deps are also converted to :foreign-libs under the hood, and it seems like a lot of work has been put into these features over the last year or two. If the approach was deeply flawed, this would seem like a big deal. On Monday, November 20, 2017 at 9:36:07 AM UTC-5, Thomas Heller wrote: > > The Closure Compiler is fully capable of this. It appears that something > is broken, don't know what. > > In shadow-cljs [1] I handle JS dependencies quite differently so not only > does this work there it is also much simpler (IMHO). > > I made a demo showcasing all of the JS interop here: > https://github.com/thheller/shadow-cljs-examples/tree/master/local-js > > You can clone it and run: > npm install > npx shadow-cljs watch app > open http://localhost:9300 > > These two files are interesting: > > https://github.com/thheller/shadow-cljs-examples/blob/master/local-js/src/demo/app.cljs > > https://github.com/thheller/shadow-cljs-examples/blob/master/local-js/src/demo/foo.js > > The CLJS files is using JS and the JS file is using CLJS. 100% full > interop. > > Note that the use of :default in the ns :require is not yet official [2]. > The support for relative require (ie. "./foo") was rejected and is "never, > ever going to happen." [3]. > > I consider this an experiment to explore alternatives to :foreign-libs as > I think they are deeply flawed and should be abandoned. > > It works well in shadow-cljs but please don't use it in any library until > there is something "official" to make all of this work. > > Cheers, > /thomas > > > [1] https://github.com/thheller/shadow-cljs > [2] https://dev.clojure.org/jira/browse/CLJS-2376 > [3] > https://dev.clojure.org/jira/browse/CLJS-2061?focusedCommentId=46191&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-46191 > -- Note that posts from new members are moderated - please be patient with your first post. --- 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 clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at https://groups.google.com/group/clojurescript.
[ClojureScript] Re: Simple es6 JS file fails to compile as foreign lib
IMHO :foreign-libs do too many things these days and its not clear what to use when or how. This feature is alpha so I expect that everything will be sorted out properly in the future. I fully expect the "flaws" to be addressed. :foreign-libs used to refer to "foreign JS" that was not processed in any way and just got prepended which was a great solution at the time and had a gigantic impact overall. It has some scaling issues but overall it works well. The biggest flaw I saw was related to mixing :foreign-libs and :npm-deps. One library may be using cljsjs.react (aka foreign lib) while a newer one maybe using "react" via :npm-deps. This would lead to a situation where you had 2 React instances in your page. Since everything also happens at the classpath level there was no proper way to "configure" it besides moving/deleting your node_modules folder which I think is pretty odd. Again: this will probably be fixed. I didn't like some of the decisions that were made and decided to build something on my own to address the issues I saw in my own code/project. YMMV. > The CLJS file is using JS and the JS file is using CLJS. 100% full interop. This is my goal and I'm close to achieving it. Cheers, /thomas PS: Someone started some boot related work started recently: https://github.com/jgdavey/boot-shadow-cljs PPS: I wrote some posts about my motivations and the implementation details in case you are interested. https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html -- Note that posts from new members are moderated - please be patient with your first post. --- 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 clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at https://groups.google.com/group/clojurescript.