Advanced compilation breaks with errors. e.g.:
"cannot read property 'prototype' of undefined" and "cannot read property '$cljs$core$IFn$_invoke$arity$1$' of undefined" for core dependencies e.g. cljs.spec, cljs.pprint and ajax.xml-http-request.
this occurred on version 2.8.74, 2.8.76 and 2.8.78.
Project successfully compiles in simple optimisations. However fails in advanced optimisations, even with --debug flag.
downgrading to 2.8.41 worked.
Is there way we can further debug and resolve these issues in the future?
Hmm sorry about that. I added a new compiler tweak that could cause this if used incorrectly/accidentially (ie. the ^not-native tag). That however would also break in development builds so I'm a bit confused. I also tested cljs.spec and cljs.pprint and those work fine. Will test the other one next.
You can try by submitting a stacktrace of where it fails when running with
shadow-cljs release app --pseudo-names
Looking at the generated JS might look strange but there should be a "namespace" somewhere with some clues.
cljs-ajax also seems to work fine although I only tested with a basic request so it may fail elsewhere.
I may make the tweaks I made "more" opt-in. They kinda already are but maybe to use incorrectly. It would really help to have some reproducible example code.
Please try 2.8.79. I put the tweaks I added behind a compiler flag so it isn't enabled by default. That should take care of it. Would still very much like to find out why it was happening though.
Just want to say that I am also experiencing issues with advanced compilation. Specifically when moving from 2.8.67 to 2.8.68 when the app loads it throws js.js:72 Uncaught ReferenceError: $jscomp is not defined coming from at okta-sign-in.entry.js:14983 via the https://github.com/okta/okta-signin-widget package
@royalaid the $jscomp issue should be fixed in newer releases. It is somehow caused by making :output-wrapper true the default even for multi-module builds. See https://github.com/thheller/shadow-cljs/issues/603.
Running against 2.8.80 leads to Uncaught TypeError: $jscomp.initSymbol is not a function
via okta-sign-in.entry.js:14983 from the same https://github.com/okta/okta-signin-widget and it also throws
Cannot read property 'prototype' of undefined
at alpha.cljs:1305
at append.js:2
Whenever an exception is thrown during load all other errors are most likely called by that missing code.
Do you have :rewrite-polyfills enabled? That seems to have gotten rather unreliable so I'd strongly recommend turning that off. Dunno why else it would try to polyfill Symbol.
Also .. what the heck are you doing adding a package that is 1.7mb in size? :P
@thheller Thank you for your response
Tried bumping to 2.8.79 and 2.8.80, still with the same results.
I've run shadow with --pseudo-names which give the following errors/stack trace.
Uncaught TypeError: Cannot read property 'prototype' of undefined
at alpha.cljs:1309
at core.cljs:177
pprint.cljs:2507 Uncaught TypeError: Cannot read property '$cljs$core$IFn$_invoke$arity$1$' of undefined
at $cljs$pprint$check_flags$$ (pprint.cljs:2507)
at $cljs$pprint$map_params$$ (pprint.cljs:2521)
at Function.<anonymous> (pprint.cljs:2550)
at $cljs$core$apply_to_simple$$ (core.cljs:3895)
at $cljs$core$apply_to_simple$$ (core.cljs:3881)
at Function.$APP.$cljs$core$apply$$.$cljs$core$IFn$_invoke$arity$2$ (core.cljs:3915)
at $cljs$core$apply$$ (core.cljs:3915)
at $cljs$pprint$consume$$ (pprint.cljs:89)
at Function.$cljs$pprint$compile_format$$ (pprint.cljs:2684)
at $cljs$core$apply_to_simple$$ (core.cljs:3895)
md5-534fe9f9d291a73d6afb0c9ef8f86be2
xml_http_request.cljs:67 Uncaught TypeError: Cannot read property 'prototype' of undefined
at xml_http_request.cljs:67
at core.cljs:226
I had a case with multi-modules there a lazy module failed to load unless I set :output-wrapper false when updating shadow-cljs from 2.8.67 to 2.8.68 (this release included a commit saying "make :output-wrapper for multi-module builds as well").
I traced the error by opening chrome devtools, selecting the Sources tab, then clicking on the Pause on exceptions button, and ticket the Pause on caught exceptions checkbox that appears.
I saw that shadow wrapper for a npm dependency would throw when using defineProperty on export. The debugger shows that the properties were already there.
.
The npm package in question is called emoji-mart and we import it like this on a lazy module:
(:require
[reagent.core :as r]
["emoji-mart/data/all.json" :as emoji-data]
["emoji-mart" :as emoji-mart])
For now we're keeping :output-wrapper false, it seems to work.
I'm seeing the same exception as @royalaid (different line numbers, depending on the exact distribution of modules) :
Cannot read property 'prototype' of undefined
at alpha.cljs:1305
at append.js:2
i only see the exception when turning on Pause on caught exceptions in chrome devtools. the exception occurs while loading/evaluating a module.
i'm using a multi-module build with output-wrapper false
haven't been able to create a minimal repro yet, but these are my current findings:
1.10.597)cljs.spec.alpha are split between different modulesi'm suspecting this because when stepping through the code in the chrome debugger, i noticed that different functions of the exact same protocol implementations were calling prototype on different objects. some of these object did exist, others did not.
hope this helps in triaging the issue, i'll try to provide some more details in the next couple of days.
@benalbrecht if you're seeing this error with clojure spec, I think you're running into https://clojure.atlassian.net/browse/CLJS-3207. The workaround is to also use s/assert on the main module.
thanks for the pointer @filipesilva! s/assert fixed it 馃槃
I ran into this issue in another project using reitit suffering the same reify related issue.
As of recent shadow-cljs versions it can be fixed by setting :compiler-options {:cross-chunk-method-motion false}. The trade-off is slightly worse code-splitting but it should be negligible.
Most helpful comment
I ran into this issue in another project using
reititsuffering the samereifyrelated issue.As of recent shadow-cljs versions it can be fixed by setting
:compiler-options {:cross-chunk-method-motion false}. The trade-off is slightly worse code-splitting but it should be negligible.