Welcome! Please see the About page for a little more info on how this works.

+3 votes
in ClojureScript by

Hi everyone,
I have a Firefox addon written cljs with advanced optimization, after submit to addons, the reviews tell me that the zip file I submit is different from what they built from source.

I use diff-so-fancy to compare the generated js file, and I found the main difference are variable names.

So is there any way to ensure generated js are reproducible?

PS: My project source code is here:

1 Answer

0 votes

A couple of years ago, I had a similar question (only in my case it was for better caching) and at least back then the answer was "no". But you might try to build with the optimizations set to simple. It also does some renaming but I think it's stable. If that doesn't work, whitespace should.

Neither `:simple` nor `:whitespace` are guaranteed to be deterministic either. Much of the randomness comes from CLJS `gensym` using an ever increasing global integer.
But `gensym` is not random. Is there random ordering then? Where does it come from?
Compilation order/timing is non-determinstic in multi threaded builds (default in shadow-cljs), as things get compiled in parallel. It might also be affected if caches are involved, as that changes what is compiled in the first place.
Does it meant that using a single-threaded build (if that's an option) along with purging the cache would solve the OP's problem?
I haven't looked at all randomness in builds, just the most obvious ones. So, possible but potentially no.