This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-06
Channels
- # announcements (4)
- # beginners (132)
- # calva (37)
- # chlorine-clover (60)
- # cider (1)
- # clara (12)
- # clj-kondo (40)
- # cljs-dev (109)
- # clojure (76)
- # clojure-dev (19)
- # clojure-europe (8)
- # clojure-france (17)
- # clojure-nl (4)
- # clojure-sg (1)
- # clojure-spec (14)
- # clojure-uk (7)
- # clojurescript (98)
- # conjure (96)
- # cursive (15)
- # data-science (2)
- # datalog (11)
- # datomic (24)
- # emacs (17)
- # figwheel-main (3)
- # fulcro (45)
- # jobs-discuss (1)
- # kaocha (3)
- # malli (2)
- # nrepl (1)
- # off-topic (135)
- # portal (2)
- # re-frame (17)
- # reagent (11)
- # reitit (4)
- # sci (60)
- # shadow-cljs (75)
- # spacemacs (3)
- # sql (32)
- # tools-deps (79)
- # vim (88)
- # xtdb (4)
clojure -Sdeps '{:deps {org.clojure/clojurescript {:git/url "" :sha "42bcb07b8bf23d57f98e4617e4c4c93347f09715"} reagent/reagent {:mvn/version "1.0.0-alpha2"}}}' -m cljs.main --install-deps
no node_modules gets created, npm
is never calledbecause in the code path that the patch touches npm-deps
will be nil rather than a map
in this case I also get an error on earlier versions of clojurescript, but at least it's shelling out to npm
npm ERR! 404 Not Found - GET - Not found
I finally got around to trying out emitting require
statements from a macro, the thing we talked about a while back (https://clojurians-log.clojureverse.org/cljs-dev/2020-05-29/1590760413.380700)
ran into two issues, the first one is small and I can submit a patch for that https://github.com/plexus/require-from-macro-test
the second issue is that the required namespaces are not actually getting compiled. Is that something that could/should work, or is it up to me to do that as part of the macro?
require
needs to be completely static and cannot be emitted dynamically like that. no macroexpansion takes place when the files are first read to gather the ns
data.
require
was only meant to work in files that don't have a ns
in the first place but are still completely static
@thheller David specifically suggested trying this approach, see the referenced conversation
yeah I saw. to get this working however you need to change a bunch of machinery and I'm not sure calling the compiler API from within a macro isn't going to lead to crazy issues.
I guess we're about to find out 🙂 this issue is for the first issue which I think is straightforward, and is separate from the question how/where/if those required namespaces should get compiled.
@plexus ok, make a issue w/ that repro - I guess I haven't run into this because I don't run that with :npm-deps
empty
@plexus the other issue is interesting, I would say unexpected since original use case (`user.cljs` and other free floating scripts) should trigger compilation of required namespaces? Any issue should talk about this more fundamental problem
well at what point is it a "dynamic require"? I'd say the example from Arne is dynamic
as in you need to macroexpand to discover new requires "dynamically". who knows what other side-effects those macroexpansions may trigger
we already have stuff like that - as long as people understand the limitations doesn't seem like there's anything to be concerned about
I understand but it makes things really annoying for tools (eg. Cursive) but also the build aspects like caching, parallel-compile, etc
I don't think that solving build related things in side-effecting macros is a good idea
heck even a simple CLJ function that just returns a "dynamic" ns
form that tools can invoke to figure out the "entries" is probably better
so unless I'm completely out of touch with the CLJS codebase there is still a parse-ns
that reads forms only until it encounters none ns
or ns*
. it then stops and analzyes the deps it found
ok, I'll make a ticket for the :npm-deps
issue, I'm not sure what the conclusion is for compiling the required files. Do I get it right that you're saying it is intended to work, and the current behavior is a bug?
well I guess the only issue I have with this is that is breaks some assumptions about caching I have built into shadow-cljs (eg. if the file doesn't change its ns
info and requires don't either)
but I guess I can easily adapt that or just automatically opt of of caching in files that have ns*
forms
but it maybe opens the doof for some more "dynamic" require and not solving those via build config (eg. (require-in-dev-only '[re-frame-10x.whatever :as x])
)
@thheller yes, I'm not saying you can't carried away but I think there are some easy problem you could solve w/o build tool support
@plexus the whole point of (require ...)
was so that you could compile scripts that don't declare ns
so I'm assuming we tested this at some point so maybe there's a narrower thing that's not working here
assuming that this is still the relevant code then it just stops when it finds ns
and doesn't look further https://github.com/clojure/clojurescript/blob/f5f9b79f6f446cef768e190971cf67fc78bf5b93/src/main/clojure/cljs/analyzer.cljc#L4439
well then it always analyzes the second form in each file and immediately discards it in most cases which may cost a bit of perf. probably not a big deal though.
@thheller definitely looks like your CLJS patch yesterday was fine and our CI setup is borked - I think what happened was that if the cache expires then WebKit master gets pulled down? will try to repro that locally and then start pinning WebKit to a known good sha that we can bump periodically
I've added a separate ticket for the CI issue and was also going to take a peek if nobody else gets to it first: https://clojure.atlassian.net/browse/CLJS-3274
FWIW, CI is still passing in the older Travis-based tests which also make use of JSC, so a JSC regression on master (or whatever is being used in GitHub actions tests) seems to be a good theory.
@dnolen Maybe this pins it sufficiently: https://github.com/clojure/clojurescript/blob/master/.travis.yml#L14
@mfikes fwiw, it might be nicer to track WebKit since then we can test against newer JS features when that makes sense?
Yeah... I'm also running a side test in CI to see what JSC is actually returning from tap>
. Maybe we can catch something ahead of time and file a ticket with JSC
adding a recur
to cljs.analyzer/parse-ns
for :ns
makes the basic case of (ns foo.bar) (require 'foo.baz)
work, I'll submit a patch for that. The next problem is that when creating the require
via a macro the macroexpansion fails, get-expander*
fails to find the macro var
if I change it to use a requiring-resolve
then it works, so this is the last thing blocking me. suggestions on how to actually fix this are welcome.
@dnolen here's the ticket for --install-deps
https://clojure.atlassian.net/browse/CLJS-3275
(ns foo.bar (:require-macros [foo.baz :refer [macro-that-requires]]))
(macro-that-requires)
that should solve itself if foo.baz
does the proper self require and you just (ns foo.bar (:require [foo.baz :refer [macro-that-requires]]))
yes, the macro is not loaded yet when it's trying to be expanded, this causes an NPE
(.findInternedVar ^clojure.lang.Namespace
#?(:clj (find-ns nsym) :cljs (find-macros-ns nsym)) sym)
@thheller the self-requires works in that the compilation succeeds, but the build is invalid, the namespace that the macro requires isn't compiled
FWIW, the CI tests are failing in JSC because it returns undefined
for setTimeout
. Details in https://clojure.atlassian.net/browse/CLJS-3274