This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-12
Channels
- # announcements (1)
- # babashka (42)
- # beginners (114)
- # bristol-clojurians (2)
- # calva (7)
- # cider (4)
- # clj-kondo (7)
- # cljs-dev (37)
- # cljsrn (13)
- # clojure (114)
- # clojure-austin (3)
- # clojure-europe (5)
- # clojure-nl (10)
- # clojure-spec (77)
- # clojure-sweden (4)
- # clojure-uk (16)
- # clojurescript (52)
- # conjure (155)
- # core-async (18)
- # cursive (23)
- # datomic (20)
- # duct (2)
- # emacs (13)
- # figwheel (3)
- # figwheel-main (9)
- # fulcro (31)
- # gis (8)
- # helix (33)
- # jobs (12)
- # jobs-discuss (66)
- # kaocha (4)
- # lein-figwheel (1)
- # meander (16)
- # off-topic (5)
- # pathom (13)
- # pedestal (6)
- # quil (6)
- # rdf (17)
- # re-frame (32)
- # reagent (34)
- # reitit (30)
- # remote-jobs (1)
- # ring (2)
- # shadow-cljs (149)
- # spacemacs (1)
- # sql (8)
- # tools-deps (90)
- # xtdb (19)
have to say, I really love node-repl for experimenting. great job and thank you for that thheller!
Just curious, what's the difference with node-repl and connect to shadow-cljs from emacs? To me it's all the same ...
I'm trying to use a Closure JS file. currently, I see the file gets loaded in the page, but when I try and evaluate anything in the namespace it provides it can't find it
I originally had it nested lilactown.harmony
and evaluating e.g. lilactown.harmony/ref
would say "cannot find namespace lilactown"
tried another thing: deleted goog.module
and tried to just treat it as a commonjs module (since goog.module
also uses exports.foo = ...
) and importing it like ["../harmony.js" :as harmony]
Hello i am looking into shadow-cljs and react native development I've used re-natal to develop hoby project before so i've got some background. i'd like to try shadow out because i've heard many, many good things about it before this point. I have few questions about this. Is there a official template for this? Basically something that allows me to create project structure for me similar how re-natal does? Also google search provided me with few examples of shadow being used with Expo which i'd like to avoid. Is there template or project that uses shadow-cljs but only vanila react native?
@lepistane the user guide has a link to an example repo: https://shadow-cljs.github.io/docs/UsersGuide.html#_react_native
so basically there is no 'template generation' this is the template to use and adopt. Thanks for the quick reply!
to be honest i've never made a template 😄 but nice idea this might be the way to do it 😄 i will have a look if i come up with it i will share it here. thanks for suggestion 😄
@lilactown importing via string only works for ESM modules, don't use commonjs exports.foo
goog.module
needs to call goog.module.declaryLegacyNamespace()
to be usable (or whatever that was called)
Hello!
Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1).
ES3
Have this error after upgrading to 2.9.1 from 2.8.90
Clojurescript version is 1.10.597I’ve seen https://github.com/thheller/shadow-cljs/issues/693 and https://clojurians.slack.com/archives/C6N245JGG/p1589065614433100 but it didn’t help much
@trybeee need to upgrade clojurescript if you update shadow-cljs. should be 1.10.758
or don't use deps.edn/project.clj to shadow-cljs can ensure you get the correct version 😛
thats what I mean. if you use deps.edn
it is in charge of dependencies. there is nothing shadow-cljs can do to ensure you get the correct versions
How does hot CSS reloading work in shadow-cljs? Should it work even if I'm not using the dev http server?
@loganpowell i’ve been working on https://github.com/Factual/geo/issues/69 Factual/geo
to cljs the last few weeks — any comments you have about potential ways to integrate census-geojson
would be appreciated! I made a (still very quiet!) #gis channel if you want to discuss there!
okay, so re: Closure JS. after clearing my build cache, adding goog.module
and declareLegacyNamespace
, it does require successfully
however, it's now failing on part of my code due to ReferenceError: $jscomp is not defined
repo: https://github.com/Lokeh/melody JS file: https://github.com/Lokeh/melody/blob/master/src/lilactown/harmony.js
I'm running a node-repl and then loading this namespace: https://github.com/Lokeh/melody/blob/master/src/melody/core.cljs
but evaluating the forms in the comment at the bottom of the file, fails at the last one: (send ,,,)
specifically the line it seems to fail on (compiled) is:
Branch.prototype.flushNext = function() {
var $jscomp$destructuring$var0 = $jscomp.makeIterator(this.unrealizedThunks);
hmm I guess its yet another scoping issue for $jscomp
. thought I got them all but guess not
I commented out
var module = module || { id: 'src/index.ts' };
goog.require('_.tslib');
is anyone here aware that using deps.edn
or project.clj
in simple projects like this that make no use of any other particular feature of those will make shadow-cljs start about 50% slower?
I see almost everyone using either these days and actually just using shadow-cljs.edn
seems to become rather rare?
I was not aware of the slowness, but I am aware of the complexity. the reason I default to deps is that I often use local roots / git deps for experimenting
well you can get the faster version by depending on thheller/shadow-cljs$aot
but I'd generally advise staying away from using that in deps/lein projects
too scary what happens with conflicts. shadow-cljs.edn can at least try to prevent some conflicts
I did it (lein) without even thinking about it, coming from clj, but I think it helps the cursive integration? knowing this, I’ll try it without
for cursive integration just run shadow-cljs pom
and load the generated pom.xml
in cursive
well thats what I do ... project.clj is fine too. really its all fine just curious why nobody is using the fastest default 😛
I expect for this specific project, I won't need any dependencies so i can just keep the deps.edn
around for external usage but use shadow-cljs.edn
for dependency resolution in-project
heya, kinda following up on https://clojurians.slack.com/archives/C6N245JGG/p1588861409381600
I was trying to set a default resolve for everything so that using a certain lib wouldn't break the node-repl
, then override it to self for the browser build (where it should work)
so something like this
;; Default all builds to resolving amplitude-js to the mock file.
;; This way node-repl doesn't break when amplitude-js tries to use `window`.
;;
:build-defaults
{:js-options {:resolve {"amplitude-js" {:target :file
:file "src/js/amplitude-mock.js"}}}}
;; On browser targets, resolve amplitude-js properly to the npm package instead.
:target-defaults
{:browser
{:js-options {:resolve {"amplitude-js" {:target :npm
:require "amplitude-js"}}}}}
turns out resolving to self is a no-no 😞
[:app] Build failure:
can't resolve to self
{:require "amplitude-js", :other "amplitude-js"}
ExceptionInfo: can't resolve to self
this looks like a perfectly reasonable error, so my question is whether there's some other way of doing this
maybe resolving "src/js/amplitude-mock.js"
to the npm target
just repeat the config to the builds that actually need it ... I mean how many can there possibly be? 😛
that's the thing though, I can't set the amplitude-js -> src/js/amplitude-mock.js
resolve on the node-repl config because that config doesn't exist
or at least that's what I got from our last conversation
suppose I could, I never saw it as just a node-script
should resolving the file to the node package also work though?
if I have a require such as (:require ["../../../amplitude-mock" :as amplitude]
, that refers to a js file in the source paths, should it be possible to use {:js-options {:resolve ...
to resolve it to a npm package instead of the js file?
gotcha
thank you
at one point I'll write a proper post how you deal with this stuff cleanly. :resolve
and hacks like it really should never ever be used. abstract it properly and you don't have to 😛
kinda have to have it because JS is so messy but it should never leak over into CLJS projects 😛
atm I'm trying to do a dynamic require in the js file instead
that sounds nicer than the other options
still not great, but confined to that single file
I made a gist while ago but never really expanded on it https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3
sometimes messing with resolve/aliasing is the only way to do things but thats really rare
so that approach is inverting the dep
makes sense
@lilactown so your issue is related to polyfills. it works fine when importing the file as ES6 but it fails when loading the file as a goog.module. not sure why yet.
that makes sense, but I would prefer to take advantage of closure’s polyfill-ability
bonus effect: Error: Namespace "demo.js_class" already declared.
can't hot-reload goog.module
files ....
I want to support shadow-cljs and vanilla cljs. vanilla cljs users have had issues with ESM in the past
I suppose for building an app with TS + CLJS, it would be better to emit ESM and feed it into CLJS that way
the opportunity to DCE and other optimize was tantalizing but probably not a big deal for app code
for this use case, it’s a library so I need to support vanilla CLJS, support DCE, etc.
I have no clue why it injects the polyfills for ESM files but not goog.module. they go through the same code path.
@lilactown ok the main issue with the polyfills is that they are never injected dynamically. so for the node-repl they aren't there from the beginning so they are never added
if you make a :node-script
build that loads the ns from the beginning they would be there
I might switch to the strategy used by the closure compiler of just injecting all the polyfills all the time and letting :advanced
remove them if not needed
goog-js but I don't think any of them require any polyfills so that never has been a problem
Just ran into an issue where I restarted my build and am now getting the Stale client!
message. Checked that index.html
is requiring the right javascript file (no changes were made to index.html
or shadow-cljs.edn
and not sure how to continue troubleshooting. Any help would be greatly appreciated!