Fork me on GitHub
#shadow-cljs
<
2020-07-03
>
neural06:07:38

Hi, i have a question about the required fields in ns declaration. Is a string not required for a npm package now ?? I mean:

(ns foo (:require ["react" :as react]))
is now
(ns foo (:require [react :as react])) ??
Because i'am getting this error in my repl (emacs/cider): &lt;&lt; could not find string alias for "react" from foo &gt;&gt; and when i change to the no string version it works fine. But how now i require something like ["@material-ui/core" :as mui] ??? i cant have a no string version because of the the @ operator! I asking here in shadow-cljs channel because i think it start to happens after i upgraded shadow-cljs from npm to the last version 2.10.13.

thheller07:07:13

@neural.works.com strings are always preferred for JS dependencies

thheller07:07:40

not sure why you are getting that error. do you have more context for what you are doing?

thheller07:07:44

and the full error?

borkdude10:07:39

What benefit has using shadow-cljs over figwheel main?

Chris McCormick11:07:17

in my experience of both, shadow-cljs feels more tightly integrated with the existing node ecosystem. you npm install shadow-cljs into your project and use a package.json rather than having the project.clj manage dependencies. importing node modules into frontend code seems smoother than it was under lein + figwheel. i am a big fan of figwheel, but i have not used figwheel for a few months and things might have changed. shadow-cljs.edn is far more concise for the most common use-cases than project.clj.

borkdude12:07:43

I'm talking about figwheel main, so the deps.edn based thing

Chris McCormick12:07:26

i don't have experience with it

borkdude10:07:53

It's ok to give a biased answer, I'm also going to ask in #figwheel-main

Paulo Casaretto11:07:43

Hey everyone! Getting started with shadow-cljs and experimenting with Preact. Couple of questions: 1. import "preact/debug"; would normally activate the debugging tools . Using it as such did in fact add the debugging tools to window as the developer extensions expected but it seems it something is off because it could not hook into the rendering process.

(ns 
  (:require ["preact/debug"]
            ["preact" :as preact]))
2. Preact offers a React compatibility layer. Do you think it would be possible to "trick" shadow.markup.react into working with Preact?

thheller13:07:40

@pcasaretto dont use shadow.markup.react but yes you can trick everything into using preact by just rewriting the react requires https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npm

thheller13:07:08

you probably want to move the preact/debug to :preloads ["preact/debug"] so its only included in dev builds

thheller13:07:32

@borkdude I've never used figwheel in any real project so I won't even start to make comparisons. The things I focussed on with shadow-cljs is easier configs with better defaults. better support for :modules / code-splitting and useful things for release builds like [build-reports](https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report)

thheller13:07:28

if you like building your own setup from scratch then shadow-cljs is not for you

thheller13:07:06

if you instead just want a tool that works with minimal config and lets you get on with your project it might be 😉

thheller13:07:46

npm integration is also a bit smoother since you don't have to worry about webpack or anything on that front

👍 3
borkdude13:07:52

my team lead isn't fond of npm in general so having to install npm to run the build may put him off

thheller13:07:03

well if you intend to use npm packages via :bundle then you'll install that regardless

thheller13:07:22

if you just want CLJSJS then definitely do not use shadow-cljs since it doesn't even support those packages

thheller13:07:51

you don't need to install npm to "run the build" though

borkdude13:07:05

yeah we use a lot of CLJSJS still

borkdude13:07:19

oh that was my impression, that you have to run npm install shadow-cljs ?

thheller13:07:34

it is recommended yes but not required

borkdude13:07:17

so shadow-cljs doesn't support working with packages from CLJSJS? - how is that?

rberger01:07:31

Shadow-cljs not working with CLSJS is a feature, not a bug. You don’t need CSJS anymore since you can so easily work directly with native npm libraries. No need to create brittle CLJSJS versions of all the libraries you want. Life is so much better this way. You can use just about any npm library you might need.

👍 3
borkdude13:07:26

ok, maybe figwheel main is the only viable option for us then right now

thheller13:07:14

if you don't intend to use npm packages then yes

thheller13:07:31

if you use npm packages then you need to get off CLJSJS anyways

borkdude14:07:03

right, we're not there yet. thanks a lot

neural17:07:25

@thheller Hi Thomas, when changing ns i am get this problem only when using strings in JS dependencies.

cljs.user=> (ns site.core)
[2020-07-03 13:59:18.978 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(ns site.core)", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (ns site.core), :source "(ns site.core)", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:519)
        shadow.cljs.repl/process-read-result (repl.clj:493)
        shadow.cljs.repl/process-input (repl.clj:673)
        shadow.cljs.repl/process-input (repl.clj:657)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:755)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:745)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045/fn--14053 (util.clj:285)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045 (util.clj:284)
        shadow.cljs.devtools.server.util/server-thread/fn--14044 (util.clj:257)
        java.lang.Thread.run (Thread.java:748)
Caused by:
ExceptionInfo could not find string alias for "react" from site.core {:require-from-id site.core, :require "react"}
        shadow.build.data/get-string-alias (data.clj:139)
        shadow.build.data/get-string-alias (data.clj:135)
        shadow.build.ns-form/rewrite-js-deps/fn--9175 (ns_form.clj:639)
        clojure.lang.PersistentArrayMap.kvreduce (PersistentArrayMap.java:377)
        clojure.core/fn--8437 (core.clj:6845)
        clojure.core/fn--8437 (core.clj:6830)
        clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
        clojure.core/reduce-kv (core.clj:6856)
        clojure.core/reduce-kv (core.clj:6847)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:636)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:628)
        shadow.cljs.repl/repl-ns (repl.clj:340)
------ REPL Error while processing ---------------------------------------------
(ns site.core)
could not find string alias for "react" from site.core
{:require-from-id site.core, :require "react"}
ExceptionInfo: could not find string alias for "react" from site.core
        shadow.build.data/get-string-alias (data.clj:139)
        shadow.build.data/get-string-alias (data.clj:135)
        shadow.build.ns-form/rewrite-js-deps/fn--9175 (ns_form.clj:639)
        clojure.lang.PersistentArrayMap.kvreduce (PersistentArrayMap.java:377)
        clojure.core/fn--8437 (core.clj:6845)
        clojure.core/fn--8437 (core.clj:6830)
        clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
        clojure.core/reduce-kv (core.clj:6856)
        clojure.core/reduce-kv (core.clj:6847)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:636)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:628)
        shadow.cljs.repl/repl-ns (repl.clj:340)
        shadow.cljs.repl/repl-ns (repl.clj:328)
        shadow.cljs.repl/process-read-result (repl.clj:513)
        shadow.cljs.repl/process-read-result (repl.clj:493)
        shadow.cljs.repl/process-input (repl.clj:673)
        shadow.cljs.repl/process-input (repl.clj:657)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:755)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:745)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045/fn--14053 (util.clj:285)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045 (util.clj:284)
        shadow.cljs.devtools.server.util/server-thread/fn--14044 (util.clj:257)
        java.lang.Thread.run (Thread.java:748)
It compiles fine, the problem is in repl

thheller17:07:52

@neural.works.com please open a github issue otherwise this will get lost