emezeske / lein-cljsbuild

Leiningen plugin to make ClojureScript development easy.
Other
1.1k stars 151 forks source link

dependencies are loaded in random order in iOS Safari causing errors #458

Closed koddo closed 7 years ago

koddo commented 7 years ago

Hello. I'm trying to run a simple re-frame example, it works in Firefox/Chrome, but doesn't in iOS Safari, because dependencies are loaded in random order. They are literally shuffled on every page reload. The app doesn't work because of this:

https://www.dropbox.com/s/o0r9hre942il1po/Screen%20Shot%202017-02-21%20at%2018.24.54.png?dl=0

Like asserts.js requires goog.debug.Error, which is in debug/error.js and is not loaded yet.

<div id="app"></div>
...
<script type="text/javascript" src="http://172.16.45.51:3449/js/compiled/out/goog/asserts/asserts.js"></script>
...
<script type="text/javascript" src="http://172.16.45.51:3449/js/compiled/out/goog/debug/error.js"></script>

And this error sometimes doesn't occur on page reload. Is there a way to fix this behaviour?

The project.clj doesn't have anything special and looks like this (https://github.com/koddo/example-cljs-reagent/blob/master/project.clj):

{:id           "dev"
     :source-paths ["src/cljs"]
     :figwheel     {
                    :on-jsload "theproject.core/mount-root"
                    :websocket-host :js-client-host
                    }
     :compiler     {:main                 theproject.core
                    :output-to            "resources/public/js/compiled/app.js"
                    :output-dir           "resources/public/js/compiled/out"
                    :asset-path           "js/compiled/out"
                    :source-map-timestamp true
                    :preloads             [devtools.preload]
                    :external-config      {:devtools/config {:features-to-install :all}}
                    ;; :closure-defines {"clairvoyant.core.devmode" true}
                    }}

Update: when built with :optimizations :advanced in min build configuration, everything works as expected, but I'd like to have figwheel.

danielcompton commented 7 years ago

So I can try to reproduce, what are the commands you're using to build your project?

danielcompton commented 7 years ago

I cloned your project, and ran

$ lein cljsbuild once dev
$ cd resources/public
$ python -m SimpleHTTPServer 3000

and was able to load the files from my iPhone by pointing it to http://<my-mac-hostname>:3000. Opening up a remote inspector on my Mac showed no issues. I'm using an iPhone SE running iOS 10.2.1.

Can you provide more instructions for reproducing this?

koddo commented 7 years ago

I found out I have iOS 9.3.5 and can't upgrade anymore because it's an old ipad mini 1, so the issue can be irreproducible.

Now the fun part. I did what you did above and tried both $ lein cljsbuild once dev and $ lein cljsbuild auto dev and served it with the SimpleHTTPServer and it worked. I then did $ lein figwheel as I usually do but still served it with python and it worked again.

I have two tabs in that outdated mobile safari: one is my_ip:3449 served by figwheel and the other is my_ip:8080 served by python. When I go to the former one, I get all those errors because of dependencies loaded in random order. When I open the latter it works. And the coolest part is the figwheel's websocket connection works and it loads changes on the fly.

So, I guess, this weird issue can be closed. Thanks for your attention and help.