This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-03
Channels
- # announcements (11)
- # atom-editor (8)
- # aws (16)
- # babashka (34)
- # beginners (59)
- # calva (32)
- # cider (8)
- # clj-kondo (43)
- # cljs-dev (52)
- # clojure (26)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-spec (16)
- # clojure-uk (44)
- # clojurescript (5)
- # core-async (21)
- # cursive (14)
- # datomic (53)
- # figwheel-main (4)
- # fulcro (5)
- # graphql (6)
- # java (3)
- # kaocha (5)
- # leiningen (6)
- # local-first-clojure (1)
- # malli (25)
- # off-topic (40)
- # other-languages (1)
- # pathom (5)
- # pedestal (3)
- # re-frame (4)
- # reitit (2)
- # reveal (8)
- # rum (21)
- # sci (16)
- # shadow-cljs (90)
- # spacemacs (8)
- # tools-deps (10)
- # vrac (6)
- # xtdb (12)
Hey! Anyone knows if it possible to hook into and change the configuration before any builds starts? I know of the :build-hooks
but they are just for a particular build. I want to be able to add new builds dynamically. ☺️
Well, I want to create node-script builds for at lot of files without having to add them all to the shadow-cljs.edn. I am looking into using Vercel (formerly zeit now) to deploy a clojurescript project. And Vercel has a folder (/api) where every file becomes a lambda function. I basically want to be able to put a *.cljs file into a folder and magically shadow-cljs produces a js file in, say /api. I could of course add them all to the shadow-cljs manually, but there could potentially be very many. Sorry of this does not make any sense 😅
(shadow.cljs.devtools.api/release* {:build-id :app :target :node-script :main 'foo.bar/main :output-to "somewhere/script.js"} {})
thats like calling shadow-cljs release app
but instead of loading the build config from shadow-cljs.edn you just pass it in directly
the map is what you'd usually have in shadow-cljs.edn
:builds
but also requires the :build-id
to be present
sounds a bit crazy to me to build one file per handler though but I can't remember if it let you load other files as well
coupled with https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run you can do pretty much anything you want
It could indeed be a bad idea, I am just experimenting 😋 I really like Vercel and shadow-cljs and really want them to work together
I have actually created a custom builder for Now that works well, but it is a bit outdated and uses old deprecated apis. https://github.com/jntn/now-shadow-cljs
(reposting from #clojurescript as i just found this channel for shadow-cljs specifically)
hi all, I’m trying to use a js lib w/ shadow-cljs and getting an error from the closure compiler about an unsupported feature `bigint` — my dependency uses `bn.js`
does anyone know how to fix this or where I can read more? i’m wondering if there is a flag i can set somewhere or if it truly is just unsupported in cljs right now…
@alexstokes need more info. how are you installing the JS library?
just npm install @chainsafe/discv5
cljs.user=> (require '["@chainsafe/discv5" :as discv5])
[2020-09-03 08:18:14.954 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(require '[\"@chainsafe/discv5\" :as discv5])", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (require (quote ["@chainsafe/discv5" :as discv5])), :source "(require '[\"@chainsafe/discv5\" :as discv5])", :tag :shadow.cljs.repl/process-ex}
shadow.cljs.repl/process-read-result (repl.clj:520)
shadow.cljs.repl/process-read-result (repl.clj:494)
shadow.cljs.repl/process-input (repl.clj:674)
shadow.cljs.repl/process-input (repl.clj:658)
shadow.cljs.devtools.server.worker.impl/fn--15149 (impl.clj:755)
shadow.cljs.devtools.server.worker.impl/fn--15149 (impl.clj:745)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14812/fn--14813/fn--14821 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--14812/fn--14813 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14812 (util.clj:257)
java.lang.Thread.run (Thread.java:834)
Caused by:
ExceptionInfo closure errors {:tag :shadow.build.closure/errors, :errors [{:resource-name nil, :source-name nil, :line -1, :column -1, :msg "Attempted to run pass \"markUntranspilableFeaturesAsRemoved\" on input with features it does not support. Running pass anyway.\nUnsupported features: [bigint]"}]}
shadow.build.closure/throw-errors! (closure.clj:1164)
shadow.build.closure/throw-errors! (closure.clj:1158)
shadow.build.closure/convert-sources-simple* (closure.clj:1902)
shadow.build.closure/convert-sources-simple* (closure.clj:1759)
shadow.build.closure/convert-sources-simple (closure.clj:2057)
shadow.build.closure/convert-sources-simple (closure.clj:2009)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1172)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1165)
shadow.build.compiler/compile-all (compiler.clj:1417)
shadow.build.compiler/compile-all (compiler.clj:1284)
shadow.build.api/compile-sources (api.clj:259)
shadow.build.api/compile-sources (api.clj:251)
------ REPL Error while processing ---------------------------------------------
(require '["@chainsafe/discv5" :as discv5])
Closure compilation failed with 1 errors
--- null:-1
Attempted to run pass "markUntranspilableFeaturesAsRemoved" on input with features it does not support. Running pass anyway.
Unsupported features: [bigint]
this looks relevant: https://github.com/google/closure-compiler/issues/3167
you can try setting your language-in / language-out to ECMASCRIPT_2019
. I’m not sure if that will resolve the compiler error or not
yeah as far as i know that lib is not using the native type so i’m not sure why the closure compiler will fail
the lib you posted relies on https://github.com/no2chem/bigint-buffer
@alexstokes yeah the closure compiler cannot transpile bigints away, so the only option is turning off ALL transpilation
:compiler-options {:output-feature-set :es-next}
I believe it the setting. let me check.
@lilactown what do you mean by "preserve line numbers"? --debug
adds source maps so you can get the original line from that?
I had an issue in production that I’m trying to reverse engineer the line numbers/symbols
no, in the production build. I haven’t figured out how to reproduce the error either
hmm then everything should be source mapped? unless your error is somewhere deep in react-dom
or so.
I think we figured it out (it was really bizarre) but in general I would like to have the source maps show in up in exceptions
if you (js/console.log ex)
chrome source maps them. if you (js/console.log (.-stack ex))
it does not I believe
@thheller neither of those :compiler-options
changed anything, but thanks for your help
it is running here
perhaps there is an issue w/ typescript?
i tried this as well and getting the same error still
:compiler-options {:language-in :es-next
:output-feature-set :es-next}
docs say :output-feature-set
replaces :language-out
thats why I suggested them separately ... try :compiler-options {:language-out :no-transpile}
:output-feature-set
is the newer option but I don't think it has a "do nothing" option
i tried both separately, will double check again
can’t get past the error w/ any of the above options
if all else fails use webpack ala https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external 😉
v20200830
is referring to a shadow-cljs release?
no the closure compiler [com.google.javascript/closure-compiler-unshaded "v20200830"]
currently is at [com.google.javascript/closure-compiler-unshaded "v20200719"]
(if you are on 2.11.x
)
ah thanks, i’ll try some of these options
I’m under the impression that returning a modified build-state
in a build hook will affect the build, but it does not appear to.
I have tried updating both :output-dir
and :closure-defines
in the :configure
stage and the build appears to use their original values. (When I log the build config in subsequent stages it is updated, but the build does not reflect the update.)
Am I misunderstanding how to modify build-state
via hooks?
(update-in build-state [:shadow.build/config :closure-defines] merge {some/other "config"})
for example if you want to override the :output-dir
of a :browser
build you need to override this value https://github.com/thheller/shadow-cljs/blob/9178e39a84108b1c0b9b26368b161a9501f4b39f/src/main/shadow/build/targets/browser.clj#L317
build-hooks run after the specific :target
implementation and the :target
implementation will already have taken everything out of :shadow.build/config
and not look at it again
so closure defines would be in (update-in build-state [:compiler-options :closure-defines] merge {})
Ah, that is likely my error…
yeah you can look at the config and get stuff for your hook from it if needed but the target usually won't use it anymore after the :configure
stage
There isn’t any pre-configure stage, is there?
Okie dokie, I’ll modify those values in their final locations. :thumbsup: