shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
stuartrexking 2021-01-28T06:43:39.213800Z

I’m trying to use https://www.npmjs.com/package/@aws-sdk/client-cognito-identity-provider from a :browser target. When I require what I need like this

(ns main
  (:require
   ["@aws-sdk/client-cognito-identity-provider" :refer [CognitoIdentityProviderClient]]))
I get an error returned
#object[TypeError TypeError: $jscomp.inherits is not a function]

stuartrexking 2021-01-28T06:44:43.214600Z

The ES6+ import example from that NPM page looks like this

import { CognitoIdentityProviderClient, AddCustomAttributesCommand } from "@aws-sdk/client-cognito-identity-provider";

jaime 2021-01-28T07:14:35.214900Z

I'd be interested to know about your workflow when working with web apps. Would you mind sharing? 😄 Do you just enable the autobuild when watching file changes?

stuartrexking 2021-01-28T08:23:31.216200Z

Upgrading shadow to the latest seemed to resolve the issue. Weird as a colleague on an older version didn’t experience it.

thheller 2021-01-28T09:09:06.216700Z

@stuartrexking that is a known issue that I have not been able to reproduce and track down unfortunately

stuartrexking 2021-01-28T09:40:06.217500Z

Fun. Thanks though.

socksy 2021-01-28T10:41:42.219700Z

going a bit crazy with a new project and tools.deps integration. Certain I had this working before. I have a deps.edn like:

{:paths ["src"]
 :deps {}
 :aliases 
 {:dev
  {:extra-deps {thheller/shadow-cljs {:mvn/version "2.9.2"}}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}}
and a shadow-cljs.edn like:
{:deps true
 :builds {:app
          {:target :node-script
           :output-to "target/main.js"
           :output-dir "target"
           :exports {:handler platform.core/handler}}}}
but when I run clj -M:dev watch app, I get
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
watch (No such file or directory)
What am I missing?

socksy 2021-01-28T10:45:33.221Z

oh fuck it was wrongly nested braces in the deps.edn. The closing brace on extra-deps line meant that :main-opts was added as an alias and so ignored. Thanks for the help 😅

wilkerlucio 2021-01-28T17:44:43.221800Z

hello, I'm having an issue to use the shadow ns in a project here, it says the namespace isn't defined, but others like shadow.cljs.devtools.server.nrepl are there, any ideas what could be wrong?

wilkerlucio 2021-01-28T17:45:26.221900Z

(shadow/nrepl-select :app)
Syntax error compiling at (REPL:1:1).
No such namespace: shadow

dpsutton 2021-01-28T17:48:28.222100Z

what did you require :as shadow?

wilkerlucio 2021-01-28T17:48:49.222300Z

nothing, I never had to, in every other project when I connect to shadow it's already there

wilkerlucio 2021-01-28T17:50:21.222500Z

I found I can fix by running the full name (shadow.cljs.devtools.api/nrepl-select :app), but found strange why only in this project I cant use just shadow/nrepl-select :thinking_face:

dpsutton 2021-01-28T17:52:22.222700Z

must have some tooling that requires it? I think CIDER might do this to start up. not sure if you're reusing a repl from that or something?

wilkerlucio 2021-01-28T17:55:26.222900Z

no, my setup is usually close to raw, simple deps with shadow, then I connect via nrepl to it

wilkerlucio 2021-01-28T17:55:41.223100Z

no plugins related to repl

wilkerlucio 2021-01-28T17:57:33.223400Z

its funny, I have a snippet to start shadow, which spits (shadow/nrepl-select $NAME$), I've been using this snippet for many years now, in many different projects (with various different setup configurations), that's why this situation puzzles me

thheller 2021-01-28T18:21:12.223700Z

check which ns you are in. should be shadow.user, that has the shadow alias.

thheller 2021-01-28T18:21:30.223900Z

but yeah to be safe use the full name

clyfe 2021-01-28T18:29:28.225100Z

> npm install bulma Can I make shadow serve css out of that node_module during dev watch & whatnot?

thheller 2021-01-28T18:31:33.225500Z

no, css is not supported

thheller 2021-01-28T18:31:55.226Z

I mean sure you can make it serve static files just fine but it won't process css in any way

👍 1
clyfe 2021-01-28T18:32:43.226100Z

I guess symlink in public is the way for now.

thheller 2021-01-28T18:32:59.226400Z

I just copy stuff personally

Helins 2021-01-28T18:40:49.228500Z

Shadow sometimes starts throwing when evaling cljs, forcing me to restart it. It happens after a while, somewhat randomly. I don't have any cljs/user.cljs file since I know that Shadow treats it specially. I guess this must be because something is missing in my config:

[2021-01-28 19:37:26.204 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 3, :from 10}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
        shadow.build.data/get-output! (data.clj:197)
        shadow.build.data/get-output! (data.clj:193)
        shadow.cljs.devtools.server.worker.impl/eval17184/fn--17187/fn--17190 (impl.clj:813)
        clojure.core/map/fn--5866 (core.clj:2753)
        clojure.lang.LazySeq.sval (LazySeq.java:42)
        clojure.lang.LazySeq.seq (LazySeq.java:51)
        clojure.lang.RT.seq (RT.java:535)
        clojure.core/seq--5402 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)

thheller 2021-01-28T19:07:37.229300Z

@adam678 which version is this? I fixed this not too long ago

Helins 2021-01-28T19:09:29.229900Z

I upgraded some time ago to 2.11.4 but it didn't go away

Helins 2021-01-28T19:09:44.230200Z

I'll upgrade again then

thheller 2021-01-28T19:10:46.230700Z

I think I fixed it in 2.11.10

thheller 2021-01-28T19:10:51.230900Z

just try 2.11.15

👍 1
clyfe 2021-01-28T20:02:07.231200Z

Failed to inspect file
  /home/clyfe/dev/riviera/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standalone-tokens.css

it was required from
  /home/clyfe/dev/riviera/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standaloneEditor.js

clyfe 2021-01-28T20:02:56.231300Z

Is there webpack integration? Seems I have to use this style-loader thing: https://webpack.js.org/loaders/style-loader/

thheller 2021-01-28T20:15:20.231900Z

like I said earlier. css is not supported.

😅 1
clyfe 2021-01-28T20:26:57.232Z

roger & apologies - I was under the impression that I'm asking different things (ie. assets bundling vs this error)

thheller 2021-01-28T21:11:41.233300Z

FWIW you can use webpack with shadow-cljs to handle this

👍 1
thheller 2021-01-28T21:12:04.233800Z

I think monaco still requires adding a webpack plugin though. not sure.

wilkerlucio 2021-01-28T21:24:23.235500Z

good point, I in this case it starts in a different ns 👍

Mark McQuillen 2021-01-28T21:27:11.237Z

Hello, I would be grateful for some help deploying an app to Heroku. I built a shadow-cljs app using: https://github.com/filipesilva/create-cljs-app Worked fine locally. But then I tried deploying it to Heroku and I got this error: "Executable 'java' not found on system path." I even tried deploying the default app provided from both my computer and Cloud9 IDE and I got the same error. Any thoughts on how to get this work? Thanks!

remote: -----> Build
remote:    Running build (yarn)
remote:    yarn run v1.22.10
remote:    $ yarn clean && shadow-cljs release app
remote:    $ rimraf public/js
remote: shadow-cljs - config: /tmp/build_8c64e158/shadow-cljs.edn
remote: ===== ERROR =================
remote: Executable 'java' not found on system path.
remote: =============================
remote: error Command failed with exit code 1.
remote:    info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
remote: 
remote: -----&gt; Build failed

thheller 2021-01-28T21:28:46.237800Z

sorry don't know anything about heroku but java will be required to build things

thheller 2021-01-28T21:29:16.238300Z

dunno why you have to build on heroku though. you could just build locally and deploy the static files

thheller 2021-01-29T09:45:09.252100Z

in your build config you have an :output-dir. lets assume that is public so everything in the public folder you put on heroku on a static site. you don't tell it about shadow-cljs or npm or java or any of that. you purely put STATIC files on heroku. I assume there is a way to do that but I don't know how.

👍 1
Mark McQuillen 2021-01-29T14:07:54.253Z

Thanks I appreciate the pointers. And thanks for shadow-cljs. It's been cool using it!

Mark McQuillen 2021-01-28T21:31:55.238800Z

Right, I built locally. I think what you're saying is that I don't have to deploy the whole repo. Is that right?

Mark McQuillen 2021-01-28T21:58:36.240Z

Would you be willing to tell me how I can do that? I tried deleting all the clojurescript files/folders but then it broke.

Mark McQuillen 2021-01-28T22:52:32.240700Z

Can someone please recommend a service to deploy a shadow-cljs app? I tried Heroku and it didn't work. Can you tell me one that does?

stuartrexking 2021-01-28T22:59:32.241900Z

@markdmcq That repo you linked to outputs a static single page app. Any static hosting site should be able to host it once you have built it.

Mark McQuillen 2021-01-28T23:00:13.243Z

I do build it. But then I get that java missing error. I think there's a problem with Heroku.

stuartrexking 2021-01-28T23:00:18.243200Z

You need java and npm to build that site though. You would normally do that on your machine before deploying (copying) the output files (html, js, css) to a static site somewhere.

Mark McQuillen 2021-01-28T23:01:36.243900Z

Yes, it gives me a public folder with javascript and css. I haven't found a way to run it though.

stuartrexking 2021-01-28T23:04:41.245Z

Once you have the static files you just need to put them somewhere that can serve them, like a webserver or CDN or a static site hosting. They won’t be run like I think you are suggesting.