Clojurians
#cljs-dev
<
2018-04-20
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

mfikes17:04:58

TIL, if foo contains

(ns foo.core)
(prn ::x)

(require 'clojure.zip)
(prn #'clojure.zip/lefts)

(ns bar.core)
(prn ::x)
then
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.238"}}}' -m cljs.main -re node foo
prints
:foo.core/x
#'clojure.zip/lefts
:bar.core/x

mfikes17:04:51

It is as if the namespace rules are relaxed in this case. (Perhaps unintentionally?)

mfikes17:04:46

It certainly makes for a more flexible scripting experience if you can have multiple top level require forms sprinkled in your script.

dnolen18:04:45

not completely unintentional, from a runtime perspective that will work

dnolen18:04:05

but of course we probably don’t handle stuff like that correct for builds

dnolen18:04:08

and don’t intend to

dnolen18:04:18

at least not as a priority

mfikes18:04:50

Cool. The motivation—if interested—is a desire to create scripts that are “standalone” in that they employ shebang and specify their own deps. This works on Linux and macOS, but relies on having strings before the ns form.

#!/usr/bin/env bash
"exec" "clojure" "-Sdeps" "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.238\"} funcool/tubax {:mvn/version \"0.2.0\"}}}" "-m" "cljs.main" "-re" "node" "$0" "[email protected]"
(ns foo.core
  (:require [tubax.core :as tubax]))
(prn (tubax.core/xml->clj "<h1>foo</h1>"))
(prn *command-line-args*)

mfikes18:04:33

It is a gross hack, but currently the only known portable working solution.

dnolen18:04:31

@r0man based on my reading your cljs.loader patch is conservative wrt. its goal? If the dependency graph changes that’s not really accounted for?

r0man18:04:44

@dnolen yes, this patch only makes sure that the module-info and module-url state does not get lost in the REPL. I can look into the merging approach also if you like. Maybe in another patch?