This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-21
Channels
- # announcements (24)
- # aws (2)
- # babashka (20)
- # beginners (147)
- # cider (20)
- # clara (43)
- # clj-kondo (3)
- # cljdoc (15)
- # cljsjs (1)
- # cljsrn (36)
- # clojars (19)
- # clojure (64)
- # clojure-europe (4)
- # clojure-italy (45)
- # clojure-nl (1)
- # clojure-spec (20)
- # clojure-uk (26)
- # clojurescript (16)
- # cursive (9)
- # datomic (18)
- # dirac (14)
- # docker (3)
- # fulcro (48)
- # keechma (1)
- # leiningen (32)
- # luminus (1)
- # off-topic (40)
- # pedestal (1)
- # quil (1)
- # re-frame (24)
- # reagent (3)
- # reitit (3)
- # remote-jobs (2)
- # ring-swagger (4)
- # shadow-cljs (115)
- # spacemacs (22)
- # specter (4)
- # tools-deps (76)
How would I delete something from the require cache in shadow-cljs/react native? Trying to time how long it takes to require a really big json object.
delete require.cache[require.resolve('./b.js')]
@ericihli I doubt react-native can do that. shadow-cljs is not part of that loading process once metro is done
hi there
I have a codebase that I am updating from shadow-cljs 2.8.67 to 2.8.83 (latest)
when this codebase is compiled in release mode, it shows an error at runtime that seems related to module loading
(this log is obtained with :pseudo-names true :pretty-print true
on the compiler options)
main.js:158 Error: 1
at main.js:3498
at $goog$module$ModuleLoadCallback$$.execute (main.js:17943)
at $JSCompiler_StaticMethods_callCallbacks_$$ (main.js:3444)
at $goog$module$ModuleInfo$$.$APP.$JSCompiler_prototypeAlias$$.onError (main.js:17977)
at $JSCompiler_StaticMethods_dispatchModuleLoadFailed_$$ (main.js:3613)
at $JSCompiler_StaticMethods_requeueBatchOrDispatchFailure_$$ (main.js:3579)
at $goog$module$ModuleManager$$.$APP.$JSCompiler_prototypeAlias$$.$handleLoadError_$ (main.js:18099)
at $JSCompiler_StaticMethods_evaluateCode_$$ (main.js:4227)
at $goog$module$ModuleLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleSuccess_$ (main.js:18605)
at $JSCompiler_StaticMethods_fireListeners$$ (main.js:3882)
it's not super clear to me how to proceed in debugging it, or what might have changed between these versions of shadow-cljs
does anyone know what it might relate to, or how I can discover what it relates to?
BTW you can run shadow-cljs release app --pseudo-names
to set those options. don't need to actually put them into the config
the closure-library/compiler were updated inbetween those versions so maybe the affects things
just open chrome, check the "pause on exception" thing and try to figure out whats wrong from there
will do, thank you
hm yeah, I found something that might make sense
$APP.$cljs$spec$alpha$t_cljs$0spec$0alpha62946$$.prototype.$cljs$spec$alpha$Spec$gen_STAR_$arity$4$ = $JSCompiler_unstubMethod$$(6, function($_$jscomp$256$$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$) {
return $APP.$cljs$core$truth_$$(this.$gfn$) ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$ ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$() : this.$gfn$.call(null) : $APP.$cljs$spec$alpha$re_gen$$(this.$re$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$, $APP.$cljs$spec$alpha$op_describe$$(this.$re$));
});
TypeError: Cannot read property 'prototype' of ...
updating shadow-cljs probably brough a new version of spec (because we didn't pin it)
and spec might have change alpha changes
yeah it seems to break when going from 2.8.71 to 2.8.72, which is when shadow updated cljs to 1.10.597
@filipematossilva maybe try setting :compiler-options {:output-wrapper false}
in case you are using multiple :modules
hmm doesn't seem to make a difference
the code changes, but the error is still the same
$cljs$spec$alpha$t_cljs$0spec$0alpha28640$$.prototype.$cljs$spec$alpha$Spec$gen_STAR_$arity$4$ = $JSCompiler_unstubMethod$$(6, function($_$jscomp$322$$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$) {
return $cljs$core$truth_$$(this.$gfn$) ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$ ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$() : this.$gfn$.call(null) : $cljs$spec$alpha$re_gen$$(this.$re$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$, $cljs$spec$alpha$op_describe$$(this.$re$));
});
Hi. Can someone point me a simple tutorial on how to spin-up a new shadow-cljs project with +re-frame dep? I was flowing http://shadow-cljs.org but now success... thanks :)
hi @thheller thanks fro your reply 🙂 So I saw that repo and I can run lein new re-frame foobar
so the process to integrade shadow-cljs comes next?
arrrggg... you are super right... I miss the "The base template includes..." text... arrgggg
running npm install (I am behind a mad proxy that blcoks me everything suspicious... lets see if i can get it here)
I think there is also lein dev
but you are going to need npm for react/react-dom anyways so ... 😛
I see some of them being installed 🙂 hope it works... I really need to start learning cljs 😄
does shadow-cljs only have built in support for expo? (not react native itself, once you eject)
just wondering if there is any way how to affect convert-sources-simple*
to not remove names from “anonymous” functions, e,g, when passing function myName(…) {}
as a callback parameter, google closure rewrites it into function (...) {}
, I understand that the name is not needed, but I have a special case where I need it, react devtools use that name for display in component tree
@darwin it should only do that rewriting when using optimizations. presumably you would want to use React devtools during dev, when you aren’t using optimizations?
@lilactown I looked through the shadow-cljs code and it seems that shadow is using closure compiler in :simple
mode to transform all stuff required via npm - that is also reason why it is minified (speaking about dev mode)
@alidcastano shadow-cljs doesn't care at all. both expo and react-native work fine. I made some demos a while ago https://github.com/thheller/reagent-react-native or https://github.com/thheller/reagent-expo
ah interesting. I couldn't get hot reloading to work when using bare react native, but will make sure to look at example and try again. thanks!
yeah you need some kind of helper since react-native doesn't allow switching the root component
so you need something like https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L33-L64
Here's my implementation, heavy with comments (not necessarily all correct). https://github.com/eihli/cljs-react-native-starter/blob/master/src/example/core.cljs
I also refer to this repo on occasion https://github.com/status-im/status-react It's a good example of a quite large app. Good ideas for structuring as you grow.
maybe I could use :js-options :resolve
in this special case and point to raw sources I see in the npm package, but I’m not sure how to specify path in :resolve
here’s an example of a reagent component, and then two components imported from NPM. the names are maintained
@darwin :js-options
takes all the regular :compiler-options
. don't know why it removes names, are you sure they aren't already gone when using the npm package? maybe that has minified sources?
@lilactown most names are maintained because those are class names or function components referenced elsewhere in the code
:resolve
only affects where the source comes from, it does not change how it is processed
@lilactown but some (small) number of componentc coud be implemented as “anonymous” functions with this name being stripped
@thheller ok, thanks for answers, I saw that in the code that it merges :js-options without :resolve key, I tried :optimizations :none as my first step and it seems to not affect the output
I’m 100% sure that the raw package tar does not contain the minified soures and the names I care about are present there
what about the babel? is it applied in this case? or it is applied only when requiring direct js files?
@lilactown just FYI, this is the issue I’m after: https://github.com/react-spring/react-three-fiber/pull/284/files#diff-d81b214c993ae261a5867e92ef560fa8R44 they merged my requests, but I’m unable to get it through shadow, because something (closure-or-babel) is stripping those names even in dev mode
hmm :variable-renaming :off
didn’t help, it was a good try
btw. I’m always deleting both .shadow-cljs and out directory, just to be sure no caches confuse my results
maybe the closure CompilerOptions has a setting thats just not exposed from the config
:js-options {:anon-fn-naming-policy :unmapped}
helpful, it gives all anonymous functions names of variables/keys which appear immediately before such anon function, in my case it gives them the exact names I want
but I’d like to have option to keep original names and maybe generate a new one only when there is no name in the first place
@thheller it looks I will need setRemoveUnusedVariables to be set to NONE, at least according to https://github.com/google/closure-compiler/blob/master/test/com/google/javascript/jscomp/IntegrationTest.java#L3825
seems like this is the actual config https://github.com/google/closure-compiler/blob/892c9054d53fab1093dabd7ef08472d9fcc9a947/src/com/google/javascript/jscomp/DefaultPassConfig.java#L2349
and that would suggest that :anon-fn-naming-policy :mapped or :unmapped
should prevent the renaming?
I think that anon-fn-naming policy would preserve the names, but some other previous pass removes them, so it sees no names and generates its own
btw. https://gist.github.com/darwin/c75123726c56e965623eba07aa660e1b did what I wanted, but you might be right that that disables a lot of other stuff I would rather don’t touch
:simple
is kind of required but if you don't care about loading extra deps in dev it should be fine
I’m a bit puzzled, now I’m trying to modify raw sources in node_modules, just to test different scenarios and it looks like my changes are not being picked up
could you confirm that shadow feeds closure with raw files from node_modules? or where is the source?
it looks like my changes in node_modules have no effect, maybe I’m touching wrong files, but that is unlikely, I don’t see anything similar around
examples/node_modules/react-three-fiber/web.js
and examples/node_modules/react-three-fiber/web.cjs.js
ah, my bad, there are two places with similar code, I was dancing at the wrong location
now it makes sense, let me do another round of tests to confirm if :anon-fn-naming-policy respects original names
ok, confirmed, case closed
:anon-fn-naming-policy
:unmapped
assings names to anon functions only if there is no previous name