This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-10
Channels
- # announcements (16)
- # asami (7)
- # aws (5)
- # beginners (46)
- # calva (47)
- # clj-kondo (3)
- # cljdoc (23)
- # clojure (70)
- # clojure-germany (1)
- # clojurescript (6)
- # community-development (2)
- # datomic (3)
- # emacs (14)
- # exercism (5)
- # hyperfiddle (4)
- # jobs (1)
- # kaocha (9)
- # lsp (13)
- # malli (6)
- # membrane (11)
- # off-topic (22)
- # pedestal (4)
- # portal (19)
- # quil (3)
- # reagent (8)
- # remote-jobs (1)
- # shadow-cljs (48)
- # spacemacs (5)
When I require clojure.string
my bundle size my bundle size jumps up 2mb. Is that normal?
( :target :npm-module
,release build, then bundled w webpack 1.15.0 )
And the bundle.js is no longer minified.
My build report says the cljs should only be about 1mb I think something in cljs is tripping up the webpack build so it ceases to minify results? I do get a smaller bundle and minified bundle.js with only a few cljs test fns. Currently I am not requiring any cljs libs (only some js ones that reside in node_modules folder). And still getting large bundle.
@chromalchemy do you use the default :advanced
optimizations or did you change it to :simple
? do you do an actual shadow-cljs release
build or just a webpack release build? did you configure webpack to inline source maps? many factors can lead to large builds, need more info to comment further.
I tried turning off source maps by removing devtool: 'source-map'
in webpack.conf.js. Also tried devtool: 'hidden-source-map'``. I am doing a
shadow-cljs release code
, then run the webpack release build.
The cljs is compiled/minified. But something is keeping the webpack build from finishishing it’s process I think. Maybe too old a version of weback. But I have been reluctant to upgrade in fear of breaking legacy js code.
Should i use :`:optimizations :advanced` explicitly?
Googling around I saw a hint that maybe ESLint errors are influencing webpack process… will have to test that.
I really cannot comment on any of the webpack bits. you can easily check the size of the generated shadow-cljs output via the :output-dir
. just make sure you ignore .map
files
should be reasonable and clojure.string
definitely won't be contributing much overall
Ignoring the cljs-runtime and node modules folders in output?
:output-dir "node_modules/shadow-cljs"
My code is only 120k! But what to the shims represent in terms of final bundle?
instead of ?
(:require
["@bigcommerce/stencil-utils" :as utils]
["jquery" :as jq]
[clojure.string :as string])
Ok I think thats what I was trying to clarify. These js deps will not be included in the shadow-cljs output (just the shim reference)
and I shouldnt need to do any $default
stuff in the require?
related, maybe.. Is this still the best way to require cljs code from js?
var clj = require("shadow-cljs/gbo.mycljs");
I don't understand what you are asking anymore. in the beginning this was about build size. now you are asking about the require?
you have the size of the CLJS code you include. if the webpack output is much larger then that is coming from your JS code and the included dependencies
Sorry, you have helped me confirm that my shadow-cljs build size is indeed very reasonable.
Thanks! Just wanted to make sure I was calling it correctly..
one last question.
I also have this in my js file, not sure where it came from. Do you recognize it?
import { clj__GT_js } from 'shadow-cljs/cljs.core';
And thank you for your help (and shadow-cljs). It’s pretty cool that I am able to surgically refactor functions into cljs inside this older theme code and it’s particular stack
True, must have been when I was trying to get cljs-devtools loading. (..never did get it working, but was able to get along pretty well with pprint)
just if (process.env.NODE_ENV === "development") { require("shadow-cljs/devtools.preload"); }
in your JS might work
Hi everyone, I wanted to use separate base_url addresses during dev and release. Is there any best practice to do that ? I found something https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env but could not figure out how to access the set variable in the code Thanks a lot
https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration