reagent

2022-11-16T17:16:30.983069Z

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

juhoteperi 2022-11-16T17:24:28.218169Z

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

2022-11-16T17:27:27.691689Z

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

2022-11-16T17:27:42.771409Z

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

2022-11-16T17:30:14.024129Z

I'm definitely invoking that build.

2022-11-16T17:30:58.729079Z

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

juhoteperi 2022-11-16T17:34:46.516509Z

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

2022-11-16T17:35:39.988729Z

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.

juhoteperi 2022-11-16T17:36:30.356499Z

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.

2022-11-16T17:36:42.610909Z

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

2022-11-16T17:37:16.304739Z

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

juhoteperi 2022-11-16T17:37:25.181719Z

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.

2022-11-16T17:37:32.256419Z

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.

2022-11-16T17:43:02.396079Z

Anyway, thanks for your attention and help.

thheller 2022-11-16T18:40:42.762369Z

what makes you think you are getting the dev build?

thheller 2022-11-16T18:41:19.974819Z

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

thheller 2022-11-16T18:41:26.851239Z

it list either the development or production file

thheller 2022-11-16T18:41:50.345149Z

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

thheller 2022-11-16T18:42:05.149009Z

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

2022-11-16T19:19:41.298989Z

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

2022-11-16T19:19:57.014369Z

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.

2022-11-16T19:21:56.584359Z

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