This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-13
Channels
- # beginners (36)
- # boot (1)
- # cider (4)
- # cljsrn (2)
- # clojure (137)
- # clojure-brasil (3)
- # clojure-czech (3)
- # clojure-italy (17)
- # clojure-nl (8)
- # clojure-spec (7)
- # clojure-uk (153)
- # clojurescript (84)
- # data-science (2)
- # datascript (13)
- # datomic (30)
- # editors (64)
- # emacs (22)
- # events (6)
- # figwheel (26)
- # fulcro (7)
- # hoplon (5)
- # jobs (5)
- # jobs-discuss (57)
- # keechma (3)
- # leiningen (4)
- # luminus (1)
- # midje (2)
- # off-topic (26)
- # portkey (18)
- # re-frame (4)
- # reagent (10)
- # ring-swagger (3)
- # shadow-cljs (135)
- # spacemacs (5)
- # sql (14)
- # tools-deps (125)
Another question @thheller: if I have a npm package which embeds css, it seems to fail to import/require the css. For example: draft.js, in ES:
import 'draft-js-static-toolbar-plugin/lib/plugin.css'
import 'draft-js/dist/Draft.css'
If I require
both in cljs, the css doesn't seem to be added. Is this the normal behaviour? If so, the best way would be, I assume, to add the css file to index.html?@mynomoto I only got 10x dev working on shadow-cljs, never on lein (well, not if I wanted to add other npm
-libraries, which was pretty much a mess)
@kurt-o-sys .css
stuff is currently not supported but might come at a later date. until then you need another way to bundle your css. unfortunately some JS libs are designed with the expectation of webpack
being used and adding all the weird conventions that entails is a bit time consuming
ok... makes sense, thx.
so, adding to index.html
will do
@danielcompton deps are done via https://github.com/cemerick/pomegranate so the exact same lib that lein
or boot
use. it is done via a standalone uberjar via shadow-cljs-jar
launched before the actual JVM. its is basically only a very tiny wrapper using pomegranate
, see https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs-jar/src/shadow/cljs/npm/deps.clj
@kurt-o-sys index.html
probably won't have access to node_modules/draft-js/dist/Draft.css
so probably need to copy it manually
@thheller right... well, I can just add https://cdnjs.com/libraries/draft-js
no need to copy.
will script it to fetch css from downloaded npm
s
ok, well, if you ever need external npm
s and you use http://blob.tomerweller.com/reagent-import-react-components-from-npm , it won't work to add 10x. The reason being: you'll take out reactjs to webpack, and 10x will not find react on startup (or someting like that). In shadow-cljs, it's no issue, since shadow-cljs inverts the logic (compile cljs to js and add it to a normal npm project - lein and boot try to embed js in their own compilation, which makes the google closure compiler cry for many npm packages). That's, at least, how I think it is ๐.
@kurt-o-sys I mean using lein to call shadow https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen I was hoping almost nothing would change except who creates the classpath and manage dependencies.
right, that's it. That's what I do as well ๐
and add :lein true
to shadow-cljs
๐
@kurt-o-sys is that setup that you were refering to about not getting re-frame-10x to work?
Looks like shadow can check the artifact on a private s3 maven but cannot fetch it whan adding :repository
. That way I can fetch the dependency using lein and run using only shadow. Adding a :plugins
seems to make no difference.
maybe its enough if I add the s3-wagon-private stuff to the classpath? no idea how this works
I think I got a good tradeoff, using lein to only fetch the dependency and shadow can go from there. I think it's interesting that it can check the dependency but not download it, but I may be misunderstanding what's going on.
maven works by always looking at ~/.m2
first so if all the deps are there there is no need to ever talk to s3
. so yeah this works but using the lein
interop is probably best since you otherwise need to manually sync the deps in shadow-cljs.edn
and project.clj
It's only one or two deps, and calling from lein is breaking re-frame-10x and I'm more willing to keep things in sync than debugging that. The odd thing is that without adding the :repositories
key it doesn't work even with the dependency cached on ~/.m2
It complains that cannot find metadata.
breaking re-frame-10x
does not make sense. it should still work if your dependencies are identical
@afhammad I don't think that is possible, how can it run in the browser then?
I mean, you are use fs
, which is node
specific
using js/require
seems to work for the same package, i thought shadow would be smart to use an appropriate import depending on the target
oh well, I am not 100% that works, let's wait for better answers
I believe it would have to do static analysis on the clojurescript code to make that work. presumably, thatโs why you do this in the namespace forms instead of in the middle of arbitrary clojurescript code: the ns form is designed to be analyzed statically
on node targets, it can just load the javascript dynamically whenever it encounters the require
this is why you end up with the immense complexity of webpack: itโs trying to figure out what to do given that you can stick a require anywhere
@afhammad js/require
is just a regular function call and not indexed by shadow-cljs. fs
is a node only package, you will get a shim if you (:require ["fs" :as fs])
in a browser build but that does not support using fs.readFileSync
node-only functionality is not available in the browser no matter how you package it
webpack uses these https://github.com/webpack/node-libs-browser and so does shadow-cljs
but youโre not going in an looking for requires and then re-writing them, are you? webpack does that. (I wouldnโt think that would be something youโd want to do)
@thheller a question about a shadow resource: does this look right?
{:cache-key [1528920986368],
:output-name "index.js",
:resource-id
[:shadow.build.targets.azure-fn/fn-index "query-events$index.js"],
:resource-name "query-events$index.js",
:type :js,
:source "module.exports = blax",
:last-modified 1528920986368,
:requires #{ep-cloud.query-events},
:provides #{}}
it is not outputed in the filesystem and maybe I am doing something wrong
@richiardiandrea uhm looks good but what are you trying to do?
I would like to write to fn-name/index.js
does not need to be compiled a guess
I saw :source
there and though I could paste my own JS ๐
you can but the resource itself does nothing. it needs to be required somewhere to become part of the compilation and output
I can push what I have if you want to have a look
I was implementing what you were describing
feel free to discard everything if not ๐
iโve been having great success translating ES6 into shadow-cljs require forms, but how about something like this:
var FileSaver = require('file-saver');
the funcpack stuff that was mentioned looks like its just webpack. could be useful as a hook though
yeah but I am not sure we need it, in any case it is good that you have a look and you validate
@spieden sorry crossed wires ๐
@richiardiandrea do you think a namespace per fn makes sense or would you want to put multiple fns into the same ns? (referring to :azure-fn
or course)
I think it makes sense...but I am passing :fn map
as is to :exports
so probably what you say is still supported?
(using :node-library
target at the moment - maybe not the right one)
@thheller yep sure
I meant to change that as well after getting it up and running
azure-app
feels better
@richiardiandrea yep picked that. master
has the updated version. your stuff went kind of the wrong direction making things more compilcated then needed
@thheller can you print the structure of your app-dir
?
I mean do you have one subfolder per function?
.
โโโ cljs
โ โโโ shared.js
โโโ host.json
โโโ local.settings.json
โโโ simple
โโโ function.json
โโโ index.js
Uhm, i just don't see where you map over the fn-map
(defn do-flush [{::keys [fn-map] :as state}]
(reduce-kv flush-fn-file state fn-map))
Oh that is where, cool
Gotcha
pushed another update that adds a check if the fn has :azure/*
metadata and fails if missing
Awesome, will validate the work on master today and report back problems in case
Yep v2
The cross validation of function params would be cool at some point, but it needs some fiddling with bindings...not a priority for me now
Wanted to get it working in func host
by today though so thanks for you help
Will try after lunch
Oh right, wow
Will try soon too
Learn a bunch of shadow today btw
Very clean approach to targets
Everything is spec-ed data, so like it
you could actually put the :azure-app
target into a library. no reason for it to be in shadow-cljs
itself
but the entire :target
stuff is completely undocumented so I don't expect anyone to write targets just yet
its easy to take the wrong path. your resource approach could eventually be done if things get more complex but for now its overkill.
@thheller I've been getting a lot of those lately:
[:workspaces] Build failure:
FileNotFoundException: resources/public/js/workspaces/main.js (No such file or directory)
java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
java.io.FileOutputStream.open (FileOutputStream.java:270)
java.io.FileOutputStream.<init> (FileOutputStream.java:213)
(io.clj:230)
(io.clj:230)
(io.clj:69)
(io.clj:166)
(io.clj:166)
I get when I'm starting from a clean compilation, and then when I try again it works
its a :browser
the :modules
output can be written before the sources are flushed. only sources create the parent dirs, the modules did not
yeah, makes sense
@wilkerlucio pushed 2.4.3
which should fix the issue (async sure is fun, brought way more issues with it than I would have expected)
async is good, and hard...
seems to be working now ๐
something got a lot faster in 2.4. one of my files caused a nearly 6 second recompile now causes a 3 second recompile
probably the new async stuff for cache writes. They can be pretty expensive and are now done in a thread pool in parallel.
@thheller I see one thing that is odd, if I change the meta on the function, the data map from the compiler does not change
it looks like it has to do with caching
(keeping the server running)
wait now it changed...weird..
opened a PR for scriptFile