Fork me on GitHub
#reagent
<
2022-11-16
>
pmooser17:11:30

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 ...

juhoteperi17:11:28

Both regular Cljs compiler and Shadow-cljs automatically use the production React build

pmooser17:11:27

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}}

pmooser17:11:42

I'm digging into my build in more detail to see if it is actually doing what I expect it to do.

pmooser17:11:14

I'm definitely invoking that build.

pmooser17:11:58

Ok, I believe I found my error. I will test and retry.

juhoteperi17:11:46

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

pmooser17:11:39

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.

juhoteperi17:11:30

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.

pmooser17:11:42

Yes, I'm definitely not setting the node env (since I don't know anything about node).

pmooser17:11:16

Yeah, I am using shadow-cljs, but this is surely something I'm doing that is weird and not a fundamental bug.

juhoteperi17:11:25

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.

pmooser17:11:32

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.

pmooser17:11:02

Anyway, thanks for your attention and help.

thheller18:11:42

what makes you think you are getting the dev build?

thheller18:11:19

you can verify what exactly you get via build reports https://shadow-cljs.github.io/docs/UsersGuide.html#build-report

thheller18:11:26

it list either the development or production file

thheller18:11:50

the size isn't much different though since things are still going through :simple optimizations

thheller18:11:05

(check react-dom, since that is the actual large one)

pmooser19:11:41

I knew I was getting the dev build due the color of the icon from react developer tools. It has a red background.

pmooser19:11:57

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.

pmooser19:11:56

I still have lots to learn about the features that shadow-cljs provides ...