This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-23
Channels
- # aws (2)
- # beginners (57)
- # boot (63)
- # cider (7)
- # clara (1)
- # cljs-dev (1)
- # cljsrn (5)
- # clojure (68)
- # clojure-brasil (1)
- # clojure-dusseldorf (2)
- # clojure-greece (10)
- # clojure-italy (29)
- # clojure-russia (1)
- # clojure-spec (9)
- # clojure-uk (66)
- # clojurescript (16)
- # cursive (18)
- # datomic (19)
- # docker (3)
- # figwheel (2)
- # fulcro (61)
- # instaparse (7)
- # jobs (1)
- # luminus (5)
- # lumo (47)
- # mount (6)
- # off-topic (13)
- # onyx (39)
- # planck (4)
- # portkey (2)
- # re-frame (28)
- # ring (6)
- # ring-swagger (30)
- # rum (3)
- # shadow-cljs (142)
- # spacemacs (5)
- # sql (2)
- # unrepl (61)
- # untangled (2)
@thheller How can I generate the bundle-info.edn file for a build?
I though shadow-cljs release my-build
would add it to the output, but I’m not seeing it
@colindresj I’m still messing around with the functionality. its not ready but you can run shadow-cljs clj-repl
and then (shadow/release-snapshot :build-id)
@cmal can’t sleep and needed to code something so I did the keyword optimization we were talking about
largest module went from 413761 bytes
-> 406811 bytes
before gzip and 53808
-> 52762
gzip’d.
you can try it with [email protected]
and setting :compiler-options {:shadow-keywords true}
Anyone gotten a fulcro
project building with shadow-cljs
? Getting an error about clojure.future
not being on the classpath, which I'm pretty sure is from https://github.com/tonsky/clojure-future-spec.
@thheller Excellent work! I will check how this will decrease my compiled and gzip'd file.
@devo @mitchelkuijpers is using fulcro
. clojure-future-spec
is ignored by default since its a backport of clojure.spec
to 1.8
but shadow-cljs
already uses clojure 1.9
last time I checked it wasn’t safe to use. I will remove the removal so the clojure.future
works again.
@cmal wrote a post about it, hope its ok that I used your numbers and mentioned you. https://clojureverse.org/t/feature-highlight-shadow-keywords/952
Yeah browser builds only for interning keywords. No risk there. Doesnt' even need a weakref
Hi. I’m testing out shadow-cljs for a node cli tool. Looks cool so far - great project!
(ns permafrost.main)
(def value-a 3)
(defonce value-b 2)
(defn reload!
[]
(println "Code updated.")
(println "Trying values:" value-a value-b))
(defn main
[ & argv ]
(println "App loaded:" argv))
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[[cider/cider-nrepl "0.16.0-SNAPSHOT"]
[refactor-nrepl "2.4.0-SNAPSHOT"]]
:nrepl
{:port 8202}
:builds
{:pf {:target :node-script
:output-to "out/permafrost.js"
:main permafrost.main/main
:devtools {:after-load permafrost.main/reload!}
:release {:output-to "permafrost.js"}}}}
@devo Send me a message if you need help, will publish a shadow-cljs starter with fulcro soon
@sundbp by default the node targets are just using :optimizations :simple
due to larger number of externs required on node setups
try compiling with :compiler-options {:infer-externs :auto :optimizations :advanced}
some DCE is still done but much less aggressive. also no renaming happens since file size usually is not that important for node.
ok. i was just surprised that not most got eliminated as i assumed just some println would bring in almost nothing
but any real code will be about that size minimum since its cljs.core with the datastructures
another assumption: if i aim to package up an npm package with a cli tool using some npm packages. I put my dependencies in package.json, do my thing. the release build will not bring in any code from the npm packages into my output, right?
i.e. i’ll get an output that has all the code from the “cljs land”, but none from the “npm land” and hence fitting in nicely with npm
https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L29-L40 thats the build config
the :npm-module
name is a bit misleading. you can use :node-library
as well which is a bit smaller and better optimizable than :npm-module
understood. wasn’t the intention - just wanted to check my understanding of what was going on
as for the npm thing I recommend outputting into a dedicated directory with its own package.json
. don’t use the one at the project root.
i’m curious about closh using lumo to run its node output: https://github.com/dundalek/closh/blob/master/bin/closh.js
lumo
is great but having it check if something needs to be compiled before running it is not useful for production builds
yes. i don’t quite understand.. because they already do a cljsbuild via lein to get an :advanced
optimization output..
so for shadow-clj cli you output to packages/shadow-cljs/cli/dist
, install a bin runner.js that loads this file with some logic around how it’s finding the file. what’s the purpose of the runner here?
if shadow-cljs
is installed globally it should still use the one installed in the project
Nice new test support works awesome
I love removing the ns that includes al test nses
Something still goes wrong with reloading but that is because the fulcro-spec runner is macro I think
@mitchelkuijpers [email protected]
also adds :target :karma
which always produces one output file (missing source maps currently, will add later)
:test-karma
{:target :karma
:output-to "out/demo-karma/test.js"}
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadless'],
basePath: 'out/demo-karma',
files: ['test.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
// FIXME: do we need this?
client: {args: ["shadow.test.karma.init"],
singleRun: true}
})
};
Ah I already had it working with browser-test 😛
It even works with karma watch
Hehe I wrote my own runner, sort of
(ns atlas-crm.CI-runner
(:require
[shadow.test :as shadow-test]
[doo.runner :as runner :refer-macros [doo-tests]]))
(doo.runner/set-entry-point!
(fn [tc]
(let [total-tests (reduce
(fn [acc {:keys [vars]}]
(+ acc (count (keys vars))))
0
(vals (shadow-test/get-tests)))]
(jx.reporter.karma/start tc total-tests))
(shadow-test/run-tests (cljs.test/empty-env :jx.reporter.karma/karma))))
had to split into a seperate namespace since shadow.test
depends on cljs.test
but shadow.test.env
needs to be loaded before cljs.test
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadless'],
basePath: 'resources/public/',
files: ['ci/js/test.js', {pattern: 'ci/js/cljs-runtime/**', included: false}],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {args: ["doo.runner.run_BANG_"],
singleRun: true}
})
};
and my shadow-cljs.edn
:ci {:target :browser-test
:asset-path "/base/ci/js"
:ns-regexp "-spec$"
:runner-ns atlas-crm.CI-runner
:test-dir "resources/public/ci/"}
Sorry have to run, hope it helps!
I really love the shadow-test stuff btw
I have to fix fulcro spec I think since it uses macros