This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-20
Channels
- # announcements (1)
- # asami (19)
- # beginners (6)
- # biff (1)
- # cljs-dev (3)
- # clojure (27)
- # clojure-europe (7)
- # clojure-gamedev (4)
- # clojure-hungary (47)
- # clojure-nl (5)
- # clojure-norway (29)
- # clojure-uk (5)
- # clojurescript (23)
- # data-science (1)
- # emacs (36)
- # events (3)
- # fulcro (22)
- # graphql (1)
- # gratitude (1)
- # introduce-yourself (3)
- # lsp (5)
- # nbb (7)
- # off-topic (68)
- # other-languages (2)
- # pathom (5)
- # reagent (4)
- # reitit (10)
- # remote-jobs (2)
- # reveal (2)
- # ring (1)
- # shadow-cljs (46)
- # spacemacs (15)
- # tools-deps (4)
What does check
actually do? ie shadow-cljs check app
There's an example in the docs, but doesn't actually say what it does
@lsenjov it runs the closure compiler type checker over the code. unfortunately that is very noisy and produces very many false positives, so I never made it an official documented feature
Hello friends 👋
We’ve recently updated a project from ClojureScript 1.10.879
to 1.11.60
and from ShadowCLJS 2.15.12
to 2.19.6
.
Since the upgrade we’re seeing a new runtime issue though: Property '$jscomp' doesn't exist
The project is a React-Native app, using the Hermes JS engine. Unfortunately https://hermesengine.dev/docs/language-features/ so we need to target ES5, but so far we could live with that.
As far as I understand $jscomp
points to an issue with polyfills not working correctly. Not sure which one specifically though.
That $jscomp
error goes away when targeting ES6, but is replaced with other ES6 issues, in particular Property 'Long' doesn't exist
. I was wondering if there’s a way to pull in polyfills explicitly using force-library-injection
, but I don’t know which polyfill would bring Long
and did not find any in https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/js/polyfills.txt inside the Closure project.
Any suggestions how to dig deeper into the issue? I’ve already tried cleaning .shadow-cljs
.
Thanks 🙌
can't say without more context. $jscomp
for polyfills or other compiler generated code that is correct.
Property '$jscomp' doesn't exist
when does it say that? did you check the generated source if its actually defined? just search for $jscomp=
or $jscomp =
? maybe it is defined just not in a way that hermes find it?
since you are using react-native doesn't metro perform the polyfilling for you? why have the CLJS do it?
Long
isn't a polyfill? its just a regular closure library class so I'm not sure how this relates?
I’ve done some more digging, here’s some more info and what I’ve found so far:
• The error at app runtime, even before a debugger can attach. There’s no stacktrace, just a oneline log in metro
• I compared the shadow output before and after the update and did some divide and conquer and found that after the update there’s a new SHADOW_ENV.evalLoad("goog.iter.es6.js"...
that wasn’t present before. Inside of it there’s a call to $jscomp.inherits(...)
which seems to be the one that triggers the error in metro (confirmed by changing the code, renaming $jscomp
to something else which changes the error output)
It seems that the es6 iter is required from various collection types now, i.e. from goog.structs.map
which in the updated version has two new requires: goog.iter.es6
and goog.collections.iters
but $jscomp should be defined regardless. did you check if it is ever assigned anywhere?
I maybe assumed that react-native is just capable of es6+ and polyfilling isn't necessary and never handled $jscomp
setup because of that
might be enough to try to prepend global.$jscomp = {}
to the generated output as a test
goog.base
contains this
var jscomp = goog.global["$jscomp"];
if (!jscomp) {
goog.global["$jscomp"] = jscomp = {};
}
but it’s part of the goog.transpile_()
just search for $jscomp.
uses in the code. it should include some assignments not just uses
This is the compiled goog.iter.es6
-> https://gist.github.com/stigi/2ac4488602b52552998fbaf74f92d28f
As far as I can tell the $jscomp.inherits
call is part of the extend from the https://github.com/google/closure-library/blob/99a2e56fd143a71ad16381c12017e53989e84b28/closure/goog/iter/es6.js#L116.
Thanks for your help already @U05224H0W. I’ll dig some more.
It seems to occur everywhere where a ES6 class is with extend is compiled with ES5 output format. Trying to come up with a small repro.
I think you can stop your investigation. I think I just assumed that react-native was capable of es6+ and never bothered to include any polyfill code at all
@U05224H0W it actually reproduces in browser trargets as well. Trying shadow vs standard CLJS compiler now and will provide a small repro.
Reproduced the issue with standard clojurescript compiler in node env. Here’s a tiny repo with a demo https://github.com/stigi/clojurescript-es5-issue
it handles all of this on its own and doesn't use anything from the regular CLJS tools
Updated the repo with shadow reproduction steps. Not sure on which project to open an issue now. My guess would be https://github.com/google/closure-compiler then.
it might be an issue in the closure compiler but I'd want to confirm that on the shadow-cljs side first
there was a closure compiler issue before where it didn't properly keep track of which polyfills were added and rewrote but didn't add polyfills
We also stumbled across this https://github.com/google/closure-compiler/issues/3879#issuecomment-948583193 that I’m working my way through right now.
Shall I open a PR adding that one to the list of existing polyfills here? https://github.com/thheller/shadow-cljs/blob/d6e14905022b719d2e240646417f53d9ee452e4d/src/main/shadow/build/closure.clj#L2568-L2585
Put up a https://github.com/thheller/shadow-cljs/pull/1035 that fixes one more issue in the react-native
target that did not yet make $jscomp
available on the global scope (node target already did so though).
Put up a https://github.com/thheller/shadow-cljs/pull/1035 that fixes one more issue in the react-native
target that did not yet make $jscomp
available on the global scope (node target already did so though).