Any hints on enabling react production builds for a reagent app? Even when I'm compiling with advanced optimizations, it seems like I'm getting the dev build, unless I'm mistaken ...
Both regular Cljs compiler and Shadow-cljs automatically use the production React build
That doesn't appear to be true. I mean, I understand that it is supposed to be true, but I have this:
:release {:compiler-options {:optimizations :advanced
:infer-externs :auto}}I'm digging into my build in more detail to see if it is actually doing what I expect it to do.
I'm definitely invoking that build.
Ok, I believe I found my error. I will test and retry.
With some tools, you are able to set NODE_ENV yourself and that will affect which React version is used, but I don't think you can do that accidentally: https://github.com/reagent-project/reagent/commit/eb3b96002fb258f9707b18063d7b4bcb73132144#diff-274071745a4e2a04b647d79d500537e6dc13eee54f44d0426140026293701d1b
Yeah, I mean I just verified that I'm using the advanced build but it's still the react dev build. Thanks for the commit - I will look into it.
That one is using Cljs compiler with npm-deps, i.e. very badly supported and a non recommended setup. Shadow-cljs, Cljs compiler with Cljsjs and Cljs compiler with Webpack etc. all work differently.
Yes, I'm definitely not setting the node env (since I don't know anything about node).
Yeah, I am using shadow-cljs, but this is surely something I'm doing that is weird and not a fundamental bug.
And you probably shouldn't set it yourself. Cljs npm-deps setup sets it by default depending on the optimization value, and I think shadow-cljs does the same.
I even verified that another app at my work has it working correctly, so I will compare my build with theirs and see if I can figure out what is different.
Anyway, thanks for your attention and help.
what makes you think you are getting the dev build?
you can verify what exactly you get via build reports https://shadow-cljs.github.io/docs/UsersGuide.html#build-report
it list either the development or production file
the size isn't much different though since things are still going through :simple optimizations
(check react-dom, since that is the actual large one)
I knew I was getting the dev build due the color of the icon from react developer tools. It has a red background.
That's great to know about the URL for the build report though - although to be clear, this is clearly my fault, and a problem with how I'm doing my build.
I still have lots to learn about the features that shadow-cljs provides ...