This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-30
Channels
- # announcements (1)
- # babashka (15)
- # calva (3)
- # cider (1)
- # clj-kondo (16)
- # clj-on-windows (1)
- # cljfx (1)
- # clojure (25)
- # clojure-europe (6)
- # clojure-spec (15)
- # cursive (13)
- # emacs (11)
- # fulcro (2)
- # humbleui (7)
- # introduce-yourself (1)
- # jackdaw (1)
- # off-topic (10)
- # pathom (5)
- # portal (3)
- # re-frame (7)
- # reagent (12)
- # releases (1)
- # shadow-cljs (8)
- # tools-build (18)
- # web-security (10)
hello. Is there a way to apply a babel transform plugin directly to shadow-cljs rather than trying to solve it by applying it post-js compilation? The one I had in mind is https://www.npmjs.com/package/babel-plugin-relay . I've seen a few ways that this had been used for vite and esbuild as well. Thank you
thank you. would a good option be to work with https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external and then use the build tool of choice to complete the process? If so, would there be a way to feed it back into shadow-cljs such that it can be served through clojure instead of a js-server?
wonderful. thank you very much for shadow-cljs and for your help! I'll try this out now
hi again. I tried the following and seem to be stuck with trying to split up the build process between shadow-cljs and babel. The following is the cleanest path I could think of:
1. run shadow-cljs compile app
using this edn:
{:lein {:profile "+shadow-cljs"}
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:app {:init-fn reagent-project.core/init!}}
:js-options
{:js-provider :external
:external-index "target/index.js"}}}
:dev-http {3000 {:root "resources/public"
:handler reagent-project.handler/app}}}
2. run babel target/index.js --out-file resources/public/js/libs.js
3. run shadow-cljs watch app
I noticed that the intermediate compiled file at target/index.js
is as shown:
// WARNING: DO NOT EDIT!
// THIS FILE WAS GENERATED BY SHADOW-CLJS AND WILL BE OVERWRITTEN!
var ALL = {};
ALL["relay-runtime"] = require("relay-runtime");
ALL["react-dom/client"] = require("react-dom/client");
ALL["react-relay"] = require("react-relay");
ALL["react"] = require("react");
global.shadow$bridge = function shadow$bridge(name) {
var ret = ALL[name];
if (ret === undefined) {
throw new Error("Dependency: " + name + " not provided by external JS. Do you maybe need a recompile?");
}
return ret;
};
shadow$bridge.ALL = ALL;
and as such, the final build file /resources/public/js/libs.js
shows the same. I was wondering if there's an obvious or few obvious things that I'm missing from this. I also tried to follow the guidance on https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external , but realized that I don't have an index.html file. I'm not exactly sure what the entry point is for an app. I apologize for the noob-ness of this question as I'm new to ClojureScript. Thank you!