Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow-CLJS release builds will fail at runtime with hashp #13

Open
filipesilva opened this issue Dec 31, 2020 · 1 comment
Open

Shadow-CLJS release builds will fail at runtime with hashp #13

filipesilva opened this issue Dec 31, 2020 · 1 comment

Comments

@filipesilva
Copy link

Heya 👋

Following the instructions in https://github.com/weavejester/hashp#shadow-cljs, a release build (e.g. shadow-cljs release app) containing #p usage will fail at runtime due to missing namespaces.

/home/filipesilva/work/relemma/out/admin.js:280
"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers212438")};return new yg(a,Id)}function Ag(a){try{var b=a[0];return b.a?b.a(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,rg(a[6]),b;throw c;}}function Cg(a,b){a=a[6];null!=b&&sg(a,b,zg(function(){return null}));rg(a);return a};function Dg(){var a=T.b(1,0)?null:1;return wg("number"===typeof a?new Yf(new Xf(Array(a)),a):a)}
                                                                                                                                                                                                 ^

ReferenceError: hashp is not defined
    at /home/filipesilva/work/relemma/out/admin.js:282:289
    at If.h.b (/home/filipesilva/work/relemma/out/admin.js:251:127)
    at Function.f [as a] (/home/filipesilva/work/relemma/out/admin.js:284:146)
    at Ag (/home/filipesilva/work/relemma/out/admin.js:280:142)
    at /home/filipesilva/work/relemma/out/admin.js:285:130
    at Immediate.hg (/home/filipesilva/work/relemma/out/admin.js:272:212)
    at processImmediate (internal/timers.js:439:21)

I understand that hashp is a debugging tool, my concern here is that leftover debugging code results in a broken build that does not fail compilation, and might not even fail on smoke tests since the failure will only occur when hitting the code path.

The only way I've found to prevent this situation is to set Shadow-CLJS to fail on release builds when there's undeclared var warnings:

{:dependencies [hashp "0.2.0"]
 :nrepl {:init-ns user}
 :builds {:app {:devtools {:preloads [hashp.core]}
                :release {:compiler-options {:warnings-as-errors #{:undeclared-var}}}}}}

This works because the build will emit the following warnings:

 variable zprint is undeclared
 Use of undeclared Var hashp.core/prefix
 Use of undeclared Var zprint.core/zprint-str
 Use of undeclared Var hashp.core/print-opts

Maybe there's a better way, but I don't know of it.

Shadow CLJS also mentions it doesn't support data readers in thheller/shadow-cljs#272, and mentions it affects caching.

@kovasap
Copy link

kovasap commented Aug 28, 2022

+1, just ran into this problem myself. Although my use case is that I actually want to use #p in a release build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants