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:
https://github.com/jiacai2050/gooreplacer/blob/firefox/cljs-src/project.clj#L76

1 Answer

+1 vote
by

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.

by
Neither `:simple` nor `:whitespace` are guaranteed to be deterministic either. Much of the randomness comes from CLJS `gensym` using an ever increasing global integer.
by
But `gensym` is not random. Is there random ordering then? Where does it come from?
by
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.
by
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?
by
I haven't looked at all randomness in builds, just the most obvious ones. So, possible but potentially no.
...