clojurescript

Schmoho 2025-03-10T12:39:17.135299Z

Is this a recoverable issue? I am trying to use https://gosling-lang.org/ again, and failing again:

[:app] Compiling ...
[:app] Build failure:
Closure compilation failed with 1 errors
--- node_modules/gosling_DOT_js/dist/gosling.js:10236
Dynamic import expressions cannot be transpiled.

p-himik 2025-03-10T12:40:42.047459Z

If you search for "Dynamic import expressions cannot be transpiled." in this channel, there will be quite a few discussions in the results.

👍 1
Schmoho 2025-03-10T12:48:02.801899Z

Hm, I think I only found this one. (*nevermind I forgot to search in shadow-cljs) Am I understanding this correctly to mean that it's categorically not possible to use stuff that uses dynamic imports for browser stuff? The comment seems to imply its not possible in the browser at all, which is weird to me because this is most definitely a browser lib https://clojurians.slack.com/archives/C03S1L9DN/p1689534348771779?thread_ts=1689532330.872299&cid=C03S1L9DN

p-himik 2025-03-10T12:52:07.225869Z

It might be that a wrong JS file is used during compilation - one that's not suitable for browsers.

Schmoho 2025-03-10T12:53:12.424009Z

It also seems that I misunderstood the comment. I will have to do some reading first to understand what I am asking in the first place, otherwise this thread will turn out a protocol of my thought process again

p-himik 2025-03-10T12:53:20.231019Z

Or it could be that it's targeted at webpack or some webpack plugin that rewrites dynamic requires into something else.

Schmoho 2025-03-10T12:59:20.293769Z

Yeah I'm seeing omens this is gonna end with trying it with webpack again

Schmoho 2025-03-10T13:16:15.190359Z

What on earth is this trying to tell me?

npx webpack --entry ./frontend/target/index.js --output-path ./frontend/resources/public/js --output-filename libs.js

Module not found: Error: Package path . is not exported from package /.../node_modules/gosling.js (see exports field in /.../node_modules/gosling.js/package.json)

Schmoho 2025-03-10T14:31:05.585539Z

Managed to get it running with Vite. My amazement is beyond words

Schmoho 2025-03-10T20:35:02.010969Z

I had to use Vite for some external dependencies, but the current setup screws with my reloading. So currently I am using the vite dev http server for the page and have a shadow watch job running. But whenever shadow recompiles, vite reloads the page, which kind of defeats the whole purpose. Is there a way to stop vite from doing that? the shadow websocket seems to be connecting just fine, so the code reload should work in principle I basically copied https://github.com/belafonte/shadowcljs-vite, got this in shadow-cljs.edn

{:js-options       {:js-provider           :external
                      :external-index        "public/js/imports.js"
                      :external-index-format :esm}}
and this vite config:
import { defineConfig } from "vite";
import { fileURLToPath } from "node:url";
import react from "@vitejs/plugin-react";

export default defineConfig({
  plugins: [react()],
  server: {
    watch: {
	// Exclude .cljs files
	// so changes dont trigger multiple reloads
	ignored: "**/*.cljs"
	// usePolling: true <- this didnt make a difference
    },
  },
});
and run the whole thing with
npx shadow-cljs -A:dev watch app & npx vite
and include it with
<script type="module" src="/public/js/imports.js"></script>
    <script defer src="/js/main.js"></script>	

p-himik 2025-03-10T20:40:17.570339Z

> Is there a way to stop vite from doing that? At the risk of stating the obvious, this doesn't seem like a CLJS question. I have no idea what Vite is and how it works, but I would guess that it has no idea how CLJS works and how shadow-cljs reloads CLJS code, and instead it does a full reloading.

Schmoho 2025-03-10T20:42:23.118679Z

Fair enough. It kind of relates to the whole saga of using JS interop, but if anything I guess it is a shadow-related question, as in "how do you make shadow and external bundlers play nicely with each other". But yeah ...

Schmoho 2025-03-10T20:51:03.834479Z

for what it's worth, seems like making vite ignore .js files instead of .cljs kind of did the trick

rafaeldelboni 2025-03-10T21:40:44.035049Z

Hey I know this is a recurring theme that keeps phoenixing back, but what you folks are using to run your cljs tests in the CI? Any karma alternatives?

Ryan Fleck 2025-03-11T21:40:27.748809Z

Is this an Elixir joke?

rafaeldelboni 2025-03-12T01:54:59.798189Z

No haha, I just have a colleague that use this "phoenixing" for discussions that keeps coming back and I thought it was common