This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-25
Channels
- # adventofcode (1)
- # announcements (1)
- # beginners (244)
- # calva (20)
- # cider (11)
- # cljs-dev (34)
- # clojure (50)
- # clojure-spec (1)
- # clojure-uk (3)
- # clojurebridge (1)
- # clojurescript (21)
- # code-reviews (1)
- # cursive (19)
- # events (1)
- # expound (1)
- # fulcro (65)
- # hyperfiddle (6)
- # luminus (3)
- # nrepl (3)
- # off-topic (23)
- # protorepl (4)
- # re-frame (18)
- # rum (11)
- # shadow-cljs (77)
- # spacemacs (8)
- # tools-deps (2)
- # unrepl (1)
- # vim (2)
any advice
is there a way to write portable libraries that include plain js files? I'm asking because by cljs standards they say to use :foreign-libs
(https://github.com/clojure/clojurescript-site/blob/master/content/reference/packaging-foreign-deps.adoc), but shadow on the other side can import js files directly, but no :foreign-libs
, I'm working in the Workspaces project and I have a dependency on a simple js file, is there a way to write it so users of the library get correct behavior with both standard cljs and shadow?
@dspiteself looks like you are using a browser build in a non browser environment? something that doesn't have access to document
@wilkerlucio the support for JS files in standard CLJS is absolutely terrible. they can't talk to CLJS code or import other code themselves
hmm maybe not actually. I'm not sure if :foreign-libs
are used before the classpath or after
@thheller so the best option seems to be create a npm package a cljsjs package and a shadow-cljsjs to get it compatible?
@thheller this is the file in question, its a fuzzy search algorithm: https://gist.github.com/wilkerlucio/221cda4bc18184ea827cbf1e545aa4a2
I even started trying to convert, but its a very stateful procedural algorithm, that's actually better as is then trying to port it to functional I think
Yea I am targeting a serviceworker which is like a webworker. https://developers.google.com/web/fundamentals/primers/service-workers/ It does not have document. It uses self.importScripts()
It seems like it would need to be a different target
@wilkerlucio I don't even know how you'd use that file with standard CLJS? did you get that working already?
if I want to target a single compiler (regular cljs OR shadow) its easy
using the foreign libs thing
the foreign lib give it a name, you require and use globals (as described here: https://github.com/clojure/clojurescript-site/blob/master/content/reference/packaging-foreign-deps.adoc)
@thheller the problem is making something that works in both cases, I can't find a way to make those compatible
you add something like this to deps.cljs:
{:foreign-libs
[{:file "react/react.js"
:file-min "react/react.min.js"
:provides ["com.facebook.React"]}]
:externs ["react/externs.js"]}
then you required the name said in the :provides
, so, in this case: (:require [com.facebook.React])
then the code is just injected
and the file is expected to set globals, so very much like adding a new <script> tag, but goes in the same bundle
the file doesn't export any globals so you rewrite the file to make it work with CLJS?
yeah, I would do that
in this case is just 3 functions that are terrible to write in cljs 😛
it sucks so bad, for such a small thing -.-
interesting, so if I make it like a google closure module I can import it directly in regular cljs?
cool, I'll try the first
a new workspaces version will be out soon, I think you might like it, some fixes and improvements, including a better spotlight (using the new fuzzy search)
sweet. I need to get back actually coding a bit .. too busy with other stuff the past few weeks
$ shadow-cljs server
shadow-cljs - config: /home/souenzzo/src/my-next-stack/shadow-cljs.edn cli version: 2.7.6 node: v11.2.0
shadow-cljs - running: lein with-profile client,webdev run -m shadow.cljs.devtools.cli --npm server
Executable '' not found on system path.
''
should be lein
🙂With figwheel, I use output-dir
on target/public/js/out
then serve target/public
and resources/public
(my index.html is on resources/public/index.html
)
(this assumes that resources
is on the classpath, which is is by default in lein
but not shadow-cljs.edn
)