bhauman / figwheel-main

Figwheel Main provides tooling for developing ClojureScript applications
https://figwheel.org
Eclipse Public License 1.0
640 stars 93 forks source link

Extra Mains path missing goog #203

Closed Folcon closed 5 years ago

Folcon commented 5 years ago

I've just been working with extra mains and I noticed that navigating to http://127.0.0.1:9500/figwheel-extra-main/devcards for example would cause these console errors:

devcards:63 GET http://127.0.0.1:9500/figwheel-extra-main/js/compiled/devcards_out/goog/deps.js net::ERR_ABORTED 404 (Not Found)
(anonymous) @ devcards:63
devcards:64 GET http://127.0.0.1:9500/figwheel-extra-main/js/compiled/devcards_out/cljs_deps.js net::ERR_ABORTED 404 (Not Found)
(anonymous) @ devcards:64
devcards:62 GET http://127.0.0.1:9500/figwheel-extra-main/js/compiled/devcards_out/goog/base.js net::ERR_ABORTED 404 (Not Found)
(anonymous) @ devcards:62
2devcards:73 GET http://127.0.0.1:9500/figwheel-extra-main/js/compiled/devcards_out/goog/deps.js net::ERR_ABORTED 404 (Not Found)
devcards:73 ClojureScript could not load :main, did you forget to specify :asset-path?
(anonymous) @ devcards:73
devcards:73 Uncaught ReferenceError: goog is not defined
    at devcards:73
(anonymous) @ devcards:73
devcards:73 Uncaught ReferenceError: goog is not defined
    at devcards:73
(anonymous) @ devcards:73
devcards:73 Uncaught ReferenceError: goog is not defined
    at devcards:73
(anonymous) @ devcards:73
devcards:73 Uncaught ReferenceError: goog is not defined
    at devcards:73
(anonymous) @ devcards:73
devcards:73 Uncaught ReferenceError: goog is not defined
    at devcards:73
(anonymous) @ devcards:73
devcards:73 Uncaught ReferenceError: goog is not defined
    at devcards:73
(anonymous) @ devcards:73
devcards:73 Uncaught ReferenceError: figwheel is not defined
    at devcards:73

This is specifically caused by these forms being appended being relative:

if(typeof goog == "undefined") document.write('<script src="js/compiled/devcards_out/goog/base.js"><\/script>');
document.write('<script src="js/compiled/devcards_out/goog/deps.js"><\/script>');
document.write('<script src="js/compiled/devcards_out/cljs_deps.js"><\/script>');

Unless I'm missing something changing them to have absolute paths in this case should fix it:

if(typeof goog == "undefined") document.write('<script src="/js/compiled/devcards_out/goog/base.js"><\/script>');
document.write('<script src="/js/compiled/devcards_out/goog/deps.js"><\/script>');
document.write('<script src="/js/compiled/devcards_out/cljs_deps.js"><\/script>');
Folcon commented 5 years ago

Well I found my error >_<...

I needed to prefix my :asset-path with a /, I had this:

:asset-path           "js/compiled/out"

instead of this:

:asset-path           "/js/compiled/out"