Fork me on GitHub
#shadow-cljs
<
2021-09-05
>
huygn10:09:52

error: Uncaught ReferenceError: document is not defined
  return goog.dom.createElement_(document, name);
                                 ^
    at Object.goog.dom.createElement 
is there any ways to prevent this error during development with :esm target? I'm consuming the output in Deno.serveHttp so document isn't a thing there. compile/release works fine, I guess it's due to dev mode always has :none optimization hence dom methods still there

thheller10:09:43

@gnhuy91 you need to set :runtime :custom in your build config. otherwise defaults to :browser which will attempt to use the dom. not related to :none in any way

💯 2
huygn10:09:20

works, thanks!

ribelo10:09:34

@gnhuy91, why are you investing so much energy in a deno which doesn't work with cljs very well?

huygn10:09:05

it's been working really well for me actually :thinking_face:

ribelo10:09:12

or otherwise, what can deno give us that node doesn't? from a cljs perspective

ribelo10:09:46

does hot reload work? last time I tried it, I couldn't get it to work properly

huygn10:09:40

deno only runs esm, and shadow can output esm which is the best match imo

ribelo10:09:55

I'm generally rooting for deno, but rather because I like it conceptually, however, I currently can't find a reason to want to use it.

huygn10:09:01

for hot reload I don't use client-side build so I don't know, but deno does reload on file changes

ribelo10:09:48

repl works normally?

huygn10:09:54

yea correct, conceptually esm & deno will led the js platform toward a more stable future

huygn10:09:37

I don't think so, repl doesn't trigger a file change, so deno won't reload

ribelo10:09:13

the only language that has a certain future is JS 🙃

huygn10:09:23

but then you could write a small shim (maybe using :init-fn) to run stand-alone with shadow-cljs, then consume the exports in deno

huygn10:09:53

what I've been doing is trying to use deno & deno deploy

huygn10:09:01

js ecosystem is slowly moving to esm format, which currently break a bunch of lib users, thus esm version is a major release for most

ribelo10:09:24

Thomas will probably create a solution in one weekend as soon as it is needed

ribelo10:09:41

so far deno has no audience in our community

borkdude10:09:34

The :esm target works for deno, this is why thheller specifically created it, but I'm also using it for #nbb (scripting on Node using SCI) to be able to import ES modules and this target also supports code splitting which allows nbb to lazily load code for better startup

huygn10:09:35

node can already consume esm imo, it's just I wanted to try deno deploy haha

huygn10:09:10

and yea it's not really about deno, it's esm

borkdude10:09:40

I tried using nbb as a library from electron, I couldn't get this working, since electron is still all about commonJS and importing ES modules from commonJS isn't possible

ribelo10:09:44

deno solves a lot of other problems that node has and esm isn't really one of them

huygn10:09:26

yea the cjs & esm compat story is a joke imo

thheller15:09:59

well its always difficult to move from a non-standard method to a standard one

thheller15:09:22

they shouldn't have delayed this for so long in the way babel/webpack did. thats the real issue, we could have been done with this for years now 😛

clojure-spin 6
Vlad Kryvokoniev15:09:43

Hi, I have problem adjusted to shadow-cljs env variables As the https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env "not clearly" says I can read a variable via `#shadow/env "TWITCH_AUTHORIZATION_TOKEN"` but instead i get an error `No reader function for tag shadow/env.` my version of shadow-cljs is "2.15.2" here is my shadow-cljs.edn:

{:source-paths
 ["src/main"]


 :dependencies
 [[reagent "1.1.0"]
  [cljs-ajax "0.8.4"]]

 :dev-http {8080 "public"}
 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn app/start}}
   :closure-defines {events.async/TWITCH_AUTHORIZATION_TOKEN #shadow/env "TWITCH_AUTHORIZATION_TOKEN"}}}} 
also my .env:
TWITCH_AUTHORIZATION_TOKEN="blalbbllba"
so my question is how to read a env variable then?