2024 Clojure状态调查!中分享您的想法。

欢迎!请查看关于页面以获取更多关于如何使用本站的信息。

+3
ClojureScript

大家好,
我有一个经过高级优化的clid Firefox插件,提交后,审查告诉我,我提交的zip文件与他们从源代码构建的不同。

我用diff-so-fancy比较生成的js文件,发现主要区别是变量名。

那么有没有什么办法可以确保生成的js是可重复的?

PS:我的项目源代码在这里
https://github.com/jiacai2050/gooreplacer/blob/firefox/cljs-src/project.clj#L76

1 答案

+1

几年前,我有一个类似的问题(在我的情况下是为了更好的缓存),但至少当时答案是“不”。但是,您可以尝试使用优化设置为simple进行构建。它也会进行一些重命名,但我认为它是稳定的。如果这不起作用,应该使用whitespace

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