This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-25
Channels
- # announcements (1)
- # beginners (338)
- # calva (41)
- # cider (19)
- # cljdoc (10)
- # cljsrn (6)
- # clojure (116)
- # clojure-europe (15)
- # clojure-italy (25)
- # clojure-nl (5)
- # clojure-spec (19)
- # clojure-uk (52)
- # clojurescript (99)
- # clojurex (14)
- # cursive (47)
- # data-science (1)
- # datomic (5)
- # duct (1)
- # figwheel (13)
- # fulcro (58)
- # graalvm (93)
- # jobs (3)
- # joker (9)
- # luminus (4)
- # nrepl (21)
- # off-topic (41)
- # pathom (25)
- # re-frame (7)
- # reitit (8)
- # ring-swagger (13)
- # tools-deps (13)
i want to build a website with lookandfeels like this: https://www.scala-lang.org/
it seems i shall go with bootstrap and buy some nice looking themes on their websites
what that makes that website looks nice is a lot of graphic design work, i doubt the framework chosen matters, but bootstrap is nice
has anyone ever successfully built un uberjar for a clojure/clojurescript app that had pure javascript dependencies through yarn
or npm
(i.e. not cljsjs
)?
it works when i use lein run
after compiling the cljs, but the uberjar is missing all of the JS dependencies at runtime
as part of building the uberjar, you need to compile the CLJS and put the resulting built artifact in the uberjar
i still haven't figured it out. i've since given up on hosting it on Heroku for this reason, and now i'm trying to do it via docker
@lilactown can i send you my project.clj
to see if theres anything obviously missing?
i can't find any documentation anywhere that explains it 😞 i've been stuck for a week now unable to deploy anywhere 😕
no, i'm currently using shadow-cljs
i tried initially with lein-cljsbuild
but it failed for some other reason
OK, cool. so it will be a two-step process:
1. Build CLJS app using shadow-cljs and put it somewhere that’s on the uberjar classpath (e.g. resources/public
)
2. Build uberjar
ok - that sounds new
i'l try that right now
currently it outputs to target/cljsbuild/public/js
let me check
i feel like it is on the classpath... it doesn't complain about the compiled file app.js
missing
in fact the error at runtime comes out of app.js
, where it adds the script tags for the NPM deps
i'm using the luminus stack
CLJS does that at runtime
it's in the compiled javascript code
it's how it loads dependencies into the DOM
a release build will not add script tags, it will bundle it all into one file app.js
this way you don’t need to have all of the npm deps installed inside of your uberjar
{:uberjar {:omit-source true
:prep-tasks ["compile" ["shadow" "release" "app"]]
:aot :all
:uberjar-name "getfluentspanish.jar"
:source-paths ["env/prod/clj" "env/prod/cljs"]
:resource-paths ["env/prod/resources"]}
this is the profile... looks like it's already tryingh to do that
it sounds like it’s doing a lot of stuff automatically for you, which is nice, but if the release artifact isn’t in the uberjar, I’m not sure
one thing is that it is bundling app.js
separately from the deps in the output folder
if you do shadow-cljs release app
and look in the env/prod/resources
folder, do you see the app.js?
i have app.js
and then a cljs-build/
directory full of hundreds of javascript files
there is nothing in env/prod/resources
except config.edn
and logback.xml
i don't think in my project that is supposed to be a build output dir
woah ok now the app.js
is bigger - 1MB compared to 128k before
after lein shadow release app
maybe we've got something now...
ok thank you
no, i believe it was what luminus gave me by default with the +shadow-cljs
addon
i.. i think it's working right now from the docker image i built
i have absolutely no idea how
i'm not sure what happened or if this is going to spontaneously revert to messing up again, but it seems like i can actually build uberjars with NPM deps now...
just for the hell of it, i'll try a heroku deploy too, but i imagine that still won't work
yep, still fails on heroku
but maybe via the docker image i can deploy to some PaaS now
@lilactown thanks a lot for your help again. I don't know what happened, but at least I understand the CLJS build process a bit better now
the docker build runs the uberjar
remote: Preparing npm packages
remote: Installing npm packages
remote: npm packages successfully installed
remote: Running shadow-cljs...
remote: [:app] Compiling ...
remote: The required JS dependency "object-assign" is not available, it was required by "node_modules/react/cjs/react.production.min.js".
remote:
remote: Searched in:/tmp/build_b5551ab5f6bbfd1f0bbb0a1210e21209/node_modules
remote:
remote: You probably need to run:
remote: npm install object-assign
remote:
remote: See:
remote:
remote: ! Failed to build.
remote: ! Push rejected, failed to compile Clojure (Leiningen 2) app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to getfluentspanish.
remote:
that's what Heroku gives me
yes, sorry I wasn't disagreeing about that, I just mean that i'm not sure what the difference is between how Heroku is building the uberjar and how I am locally
it worked via docker on Heroku 🎉
it just goes down a rabbithole
it is then missing another dependency
and then another
every implicit dependency of the listed NPM deps
unfortunately, although it sort of works now, i get mysterious runtime javascript errors
Uncaught TypeError: Cannot read property 'b' of null
at app.js:1470
at dE (app.js:1470)
at eE (app.js:1470)
at app.js:1474
at Object.drop (app.js:428)
at app.js:296
at Array.forEach (<anonymous>)
at a.<anonymous> (app.js:296)
at Object.drop (app.js:336)
at handleTopDrop (app.js:487)
when i try to use a drag and drop activity i wrote
probably something with the minification...
or optimizations
i don't know
nothing ever just "works" haha 😞
i'll play around with it
you can add —debug
to the shadow-cljs release command so it will have easier to read names
ok i'll take a look