This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-29
Channels
- # announcements (17)
- # aws (12)
- # babashka (27)
- # beginners (85)
- # bristol-clojurians (1)
- # calva (16)
- # cider (3)
- # clara (7)
- # clojure (80)
- # clojure-europe (13)
- # clojure-italy (19)
- # clojure-nl (2)
- # clojure-norway (6)
- # clojure-poland (1)
- # clojure-spec (31)
- # clojure-uk (61)
- # clojurescript (29)
- # core-async (10)
- # cursive (7)
- # data-science (1)
- # datomic (29)
- # docker (3)
- # fulcro (120)
- # graphql (16)
- # hugsql (2)
- # leiningen (17)
- # luminus (2)
- # off-topic (36)
- # other-languages (3)
- # pathom (13)
- # re-frame (12)
- # ring (2)
- # rum (1)
- # shadow-cljs (126)
- # tools-deps (56)
- # vscode (5)
Wow. shadow-cljs is amazing! I’m amazed at how wonderful the CLJS REPL is, and how fast the code loads in the browser! Thank you for all your wonderful work, @thheller!
I have a question that I’m hoping someone with more npm experience can easily answer… . I was using the linkify
npm module via cljsjs
in a figwheel project.
I’m trying to convert it over to shadow-cljs
and for the life of me, I can’t figure out how to get the syntax of the require
correct.
In the GitHub repo, the instructions are: https://github.com/SoapBox/linkifyjs/
var linkify = require('linkifyjs');
require('linkifyjs/plugins/hashtag')(linkify); // optional
var linkifyHtml = require('linkifyjs/html');
So, following the instructions, I tried this:
(:require
["linkifyjs" :as l]
["linkifyjs/hmtl" :s lh])
But I keep getting errors like:
The required JS dependency "linkifyjs/hmtl" is not available, it was required by "trello_workflow/io.cljs".
Search in:
/Users/genekim/src.local/trello-workflow/node_modules
You probably need to run:
npm install linkifyjs/hmtl
See:
How does one get access to the linkifyHtml
function?
Many thanks in advance! And keep up all the great work, @thheller!!!PS: In my desperation to get things running again, I even tried switching to the goog.string.linkify
library in Google Closure, but wow, their SafeHtml classes are way too effective — I couldn’t replicate all my dangerous hacks I was using! 🙂
OMG. You’re right @sogaiu — I had a typo! (I’ve been banging my head on this for 90m. I think I had it right in an earlier iteration…) Wait, more typos… oh, hey!
lh
=> #object[Function]
(lh "")
=> "<a href=\"\" class=\"linkified\" target=\"_blank\"></a>"
Thank you so much!!! 🎉 🎉 🎉 🎉PPS: @thheller Your documentation is superb. For the first time in three years, I finally have some reasonable understanding of what a classpath is! (Your description of the source-paths was a huge lightbulb moment for me.)
also very much appreciate the docs :thumbsup: on a side note, i found the following seancorfield article to be very informative wrt classpaths and some clojure-related tooling: https://corfield.org/blog/2018/04/18/all-the-paths/
Thank you!! Superb article!!! Thx to you and @U04V70XH6 !!!
Hey, sorry didn't realize there are other channels! I posted in #clojurescript but maybe this is more appropriate. Here's a link to what I posted : https://clojurians.slack.com/archives/C03S1L9DN/p1580280756468800
Hi 🙂. I’m wonder if there is a trick to have code splitting with expo
and react-native
for the web target?
@jean.boudet11 I did some prep work for that and it works in theory but I have no idea how to make react-native actually lazy load the code. it requires messing with some rather weird react-native/metro internals that I don't know how to get working. https://facebook.github.io/react-native/docs/performance#ram-bundles--inline-requires
Ok thanks! In fact, expo
can use react-native-web
to target the web but in shadow-cljs
the build target react-native
. I try to use a target web for react-native-web
without expo
but not work for the moment because of ui-kitten
.
About replacing the <latest>
placeholder with "LATEST"
. It seems that in Maven 3, both "RELEASE"
and "LATEST"
are missing: https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-PluginMetaversionResolution
The maven-resolver-api
that's used by tools.deps still seems to support "RELEASE"
though, but I cannot find any specific information about it.
hmm yeah might be "RELEASE", not exactly sure. I saw something used in a project that wasn't an actual version and was surprised to learn it worked 😛
Well, the code of tools.deps does have a special clause for handling "RELEASE" and "LATEST" specifically. But I can't find any proper mention of these aliases in the tools.deps documentation as well. So maybe it's just legacy stuff left in there because Maven 2 used to support it, no idea.
yeah I'm always wary of "magic" version numbers but having to look up the latest version isn't great either
Hmm. Now I think that for a build tool, using such an alias is not really appropriate though. It will lead to situations where I develop with one shadow-cljs version, test with another one, deploy with the third one. And just to avoid going to the homepage of every single library I use, I find https://github.com/Olical/depot quite sufficient. :)
thats for finding newer versions. you still need to know at least one version to use it 😛
I may add something like shadow-cljs find-versions reagent
or something like that some day
but given that I already have a billion other features planned that'll probably take a while 😛
Right, that makes sense.
Maybe even shadow-cljs add-dep reagent
or something like that. :)
But that asks for a different project. Or maybe a PR for depot.
I thought about add-dep a lot but its just not gonna work. programmatically editing shadow-cljs.edn (or deps.edn) destroys all the formatting and comments the user may have done
and I'm very sensitive to my config file structure. it changing "randomly" is not something I would accept
might be doable with something like rewrite-clj but that is also rather difficult to use 😛
Oh, right.
Well, it should be possible to always add the requested dependency right at the end of the :deps
map. Although it may require hooking into the EDN parser or even writing your own to know exactly where that }
is (never tried or even read about rewrite-clj, no idea here).
I'd argue that it would be enough for the vast majority of cases. And for the rest, the user can always fix the file manually, especially when using any VCS. The heavy lifting of getting the version and putting the coordinates into the file has already been done.
But even just printing out the coordinates is much better than nothing, that's for sure.
at some point I also wanted to generate build configs and such from templates but never could figure it out. I don't like templates that have even on incorrectly indented output :P
Hey @thheller just wanted to pop in and say I have started to refactor based on your recommendations. It is SO MUCH BETTER 🙌 ty again for the advice
I seem to be having trouble requiring js files into shadow-cljs (react native project). Am I importing it in wrong? My Error:
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
File: /Users/jeeq/Documents/rnproj/src/js/rnproj/home.js:6:5
--------------------------------------------------------------------------------
3 |
4 | function Home(props) {
5 | return (
6 | <Svg width={16} height={16} viewBox="0 0 16 16" fill="none" {...props}>
-----------^--------------------------------------------------------------------
primary expression expected
--------------------------------------------------------------------------------
7 | <G clipPath="url(#prefix__clip0)">
8 | <Path
9 | d="M11 16h2c.6 0 1-.4 1-1V8h1c.3 0 .6-.1.8-.3.4-.4.3-1-.1-1.4l-7-6C8.3 0 7.8 0 7.4.3l-7 6c-.4.4-.5 1-.1 1.4.1.2.4.3.7.3h1v7c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-3h4v3c0 .6.4 1 1 1z"
10 | fill="#546BFB"
--------------------------------------------------------------------------------
It seems to be able to find the js file but not parsing it correctly. I have a line in my :require, [“./home” :as svghome :refer (Home)]
home.js is svg converted to “appropriate” format by tool linked by react-native-svg (https://svgr.now.sh/)
import React from "react";
import Svg, { G, Path, Defs, ClipPath } from "react-native-svg";
function Home(props) {
return (
<Svg width={16} height={16} viewBox="0 0 16 16" fill="none" {...props}>
<G clipPath="url(#prefix__clip0)">
<Path
d="M11 16h2c.6 0 1-.4 1-1V8h1c.3 0 .6-.1.8-.3.4-.4.3-1-.1-1.4l-7-6C8.3 0 7.8 0 7.4.3l-7 6c-.4.4-.5 1-.1 1.4.1.2.4.3.7.3h1v7c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-3h4v3c0 .6.4 1 1 1z"
fill="#546BFB"
/>
</G>
<Defs>
<ClipPath id="prefix__clip0">
<Path fill="#fff" d="M0 0h16v16H0z" />
</ClipPath>
</Defs>
</Svg>
);
}
export default Home;
that is not a javascript file. that is a JSX file and JSX is not supported by shadow-cljs
Hello! I’m configuring running tests in browser. Is there a way to know what ns
is going to be reloaded in start
fn call in runner-ns
?
Currently start
would run whole test suite, but i’d like to run tests from recompiled ns only. I tried using build-hooks for that which is getting build-state
object. Idea was to store recompiled ns somewhere in global var and then use it in runner-ns start
fn.
please open an issue on github so I don't forget. have to finish up some other stuff first but its a relatively easy add so should be quick once I'm done with this.
@thheller doh! Of course. Guess my mind was elsewhere. Thank you. I’ll try using babel to convert as suggested in the doc
how might i go about diagnosing the root cause of this?
------ ERROR -------------------------------------------------------------------
File: jar:file:/Users/robert/.m2/repository/org/clojure/clojurescript/1.10.597/clojurescript-1.10.597.jar!/cljs/core.cljs:999:14
--------------------------------------------------------------------------------
996 | (if (js/isFinite o)
997 | (js-mod (Math/floor o) 2147483647)
998 | (case o
999 | ##Inf
--------------------^-----------------------------------------------------------
No reader function for tag Inf
--------------------------------------------------------------------------------
1000 | 2146435072
1001 | ##-Inf
1002 | -1048576
1003 | 2146959360))
--------------------------------------------------------------------------------
https://stackoverflow.com/questions/48039878/cljs-core-cljs-line-988-col-14-no-reader-function-for-tag-inf says i need org.clojure/tools.reader 1.1.0` at least, but i've checked, i have
org.clojure/tools.reader 1.3.2
on the classpath (according to clj -Stree
)
hmm yes that is normally cause by having a CLJS version that doesn't match its required tools.reader version
are you sure you checked your -Stree
with all the aliases active you'd have active for cljs?
yes, with all aliases on, org.clojure/clojurescript 1.10.597
and org.clojure/tools.reader 1.3.2
bit of a head-scratcher
try running clj
(with the aliases) and then (
(require first)
looks correct
user=> ( "clojure/tools/reader.clj")
#object[.URL 0x1c7fd41f "jar:file:/Users/robert/.m2/repository/org/clojure/tools.reader/1.3.2/tools.reader-1.3.2.jar!/clojure/tools/reader.clj"]
I have version 2.8.83 of shadow cljs and my shadow-cljs.edn file looks like so: {:app {:devtools {:preloads [shadow.remote.runtime.cljs.browser
When i run shadow-cljs watch app
it tells me the shadow.remote.runtime.cljs.browser ns isn't available. I'm not sure what else to try.
are you sure you have 2.8.83? it is a common mistake for people using deps.edn/project.clj to update the the npm install but not the clj side
yes. thats the problem
@robert-stuttaford don't even know if the shadow-cljs version is relevant here but which one do you have?
would a discrepancy between package.json and deps.edn mess with that? package.json "^2.8.83" deps.edn "2.8.48"
only guess I have is that you have some AOT compiled version of the old tools.reader on the classpath
mf!
#object[
boom! dunno if its possible to figure out what version thats actually from but thats likely the problem
i'll try to exclude tools.reader on the datomic dep
is it possible to remove deps when a profile is activated? something like :override-deps {datomic false}
or so?
totally hear you. i'll move to a cljs alias
now its telling me the build failed because clojure.datafy is not available. maybe I have clojure version 1.10.1 maybe that needs to be bumped?
great question, i'll check
@drewverlee your CLJS build failed? maybe you also have a bad CLJS version?
well specifically it says:
The required namespace "clojure.datafy" is not available, it was required by "shadow/remote/runtime/shared.cljc".
"clojure/datafy.clj" was found on the classpath. Should this be a .cljs file?
Sorry. Ill just come back to this later. Im probably missing something obviousI should write a blog post "yes, you might have a dependency conflict. no, that wouldn't happen if you put your CLJS dependencies in shadow-cljs.edn as recommended" 😛
we switched our biggest codebase to shadow this week. knocked 40% off our build time.
i'm still dragging ours over. i ran into some timing issues. i'm assuming we have some races in navigation now but they are working correctly. get errors on nav at the moment
benchmarking JS is extremely tedious ... anyone know of tools to automate this better?
I'm trying to setup a system that runs various shadow-cljs+CLJS combinations through a benchmark suite and collect the results
I've made one rather big change and I want to test if thats actually worth performance wise
;;; fn invoke
{:standardDeviation 0.023446214753117665, :bindings "[val (rand)]", :maximum 1, :total 11, :expr "(simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00055}
{:standardDeviation 0.027376540573065246, :bindings "[val (rand)]", :maximum 1, :total 15, :expr "(simple-fn-indirect simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00075}
{:standardDeviation 0.029143094653764887, :bindings "[val (rand)]", :maximum 1, :total 17, :expr "(simple-fn-indirect-hinted simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00085}
Sorry to keep bothering about something that may or may not be supported in shadow-cljs right now but I’m now trying to get the example in the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects) to work in my project (expo/react-native not sure if this is the issue). example jsx I’m trying to get working:
import React from "react";
function myComponent() {
return <h1>JSX!</h1>;
}
export { myComponent };
when I conver this jsx to js with babel as in the docs I get error message about shadow.js.shim… not being provided:
Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefault
construct
[native code]:0
_construct
construct.js:30:26
Wrapper
wrapNativeSuper.js:26:23
SyntheticError
index.bundle?platform=ios&dev=true&minify=false&hot=false:31652:111
handleException
ExceptionsManager.js:111:31
handleError
setUpErrorHandling.js:23:40
ErrorUtils.setGlobalHandler$argument_0
ErrorRecovery.fx.js:8:32
tryCatch
runtime.js:45:44
invoke
runtime.js:271:30
tryCatch
runtime.js:45:44
invoke
runtime.js:135:28
Promise.resolve.then$argument_0
runtime.js:145:19
tryCallOne
core.js:37:14
setImmediate$argument_0
core.js:123:25
_callTimer
JSTimers.js:146:14
_callImmediatesPass
JSTimers.js:194:17
callImmediates
JSTimers.js:458:30
callImmediates
[native code]:0
flushedQueue
[native code]:0
invokeCallbackAndReturnFlushedQueue
[native code]:0
Without the import line and if I just set to return a simple number (i.e. return 2;) I’m able to use the exported module. It just seems to be confused when trying to import any modules.
Any pointers?but you are using react-native anyways so you should figure out a way to let react-native compile the js files and not shadow-cljs
just used the example on the doc but with option for transform inlined
babel --plugins @babel/plugin-transform-react-jsx src/js --out-dir src/gen
likely that means not requiring the file via ns
and instead do (def thing (js/require "../path/to/home.js"))
and what does the generated output file look like? it looks like it rewrote ESM import to require which it should not do
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", { value: true });
exports.myComponent = myComponent;
var _react = _interopRequireDefault(require("react"));
function myComponent() {
return 8;
}
This is the output from babelI did a setup several years ago. maybe that still works? https://github.com/shadow-cljs/examples/tree/master/babel
I’ll try to figure out if I can turn that off and also will try requiring with js/require
Hi, I have a re-frame app from which I wanted to extract some functionality, and I want to share that funcitonality with other components I have done in the past
I’ve read that I can use lein to generate a jar, so I can do that locally, and then how can I include that generated jar in my component using shadow?
@wvelezva I can tell how it works if your library is public/open source. otherwise you are probably better off using deps.edn
and putting the files in a git repo or local folder
@thheller ok, so I think I better use deps.edn
but in general what I should create? a normal cljs component? I have to generate the js? or something like a jar, npm?
or can use lein to manage my dependencies and install the component like a jar?
you don't have to compile anything. the easiest way to share components is to just put them in their own namespace
and then either add the path to that into your :source-paths
or use lein install
and add the dependency
oh, I didn’t know that was possible
I will give it a try
thank you
things get a bit more complicated if you want to declare dependencies in the library, at which point you should likely go with deps.edn
Is there a recommended way of rendering images in react native? I’m using the method described in this example https://github.com/PEZ/rn-rf-shadow/blob/master/src/main/example/app.cljs#L16