This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-08
Channels
- # babashka (1)
- # babashka-sci-dev (27)
- # beginners (13)
- # cljdoc (1)
- # clojure (24)
- # clojure-austin (1)
- # clojurescript (76)
- # data-science (18)
- # datomic (7)
- # java (2)
- # malli (7)
- # nbb (7)
- # off-topic (34)
- # portal (1)
- # reagent (9)
- # reitit (4)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (11)
- # squint (7)
- # tools-build (7)
- # uncomplicate (1)
Squint needs a common-js bundle. Just dropping this here this Sunday night right before I go to bed 😄 Reason: Most common-js tools do not play nice with esm and most JavaScript tools are common-js. (almost verbatim stolen from here: https://adamcoster.com/blog/commonjs-and-esm-importexport-compatibility-examples#advice ) Instructions how to do it: https://antfu.me/posts/publish-esm-and-cjs I can create an issue for it if not out of the question Anyways, good night and thanks for all the tools you give us 🙂
I think it's better to come up with a real example that demonstrates the problem. What tools for example
Yes, sorry for not giving more specifics yesterday: just wanted to drop it, so I have to follow up. One example: The output of Remix builds is cjs, not esm. As soon as I import something from squint I get the error:
Error [ERR_REQUIRE_ESM]: require() of ES Module (...)/node_modules/squint-cljs/core.js from (...)/build/index.js not supported.
Instead change the require of core.js in (...)/remix-squint/build/index.js to a dynamic import() which is available in all CommonJS modules.
Yesterday I changed squint/core.js to cjs using https://sidvishnoi.github.io/esm-to-cjs/ and removed the type: module
from package.json and it worked.
But I'm also not building anything serious right now, just playing around, so no urgency here in any way.Wouldn't you be able to use Remix with Clojurescript? Since it's all backend Node.js ?
I don't know the answer to the first question, but regarding the second: The Remix compiler runs in nodejs, but Remix itself runs in many places. I've primarily deployed it to Cloudflare, which isn't Node.js. And it's not just backend runtimes but also code that runs in the browser. (but perhaps I misunderstand your question and you only meant the compiler). Short example of a route file:
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
export function loader() {
return json({ hello: "World" })
}
export default function App() {
let data = useLoaderData()
return <h1>{data.hello}</h1>
}
The loader will only ever run on the server, becoming a GET endpoint, while the App is server rendered only on page load, after that it's part of a "normal" React app running in the browser.
Coming back to your first question: You could well be right that Clojurescript itself would be enough. I don't know enough to be sure, only working in Clojurescript since September (but following developments in the ecosystem way longer).
ClojureScript and shadow could probably work here but Squint's more 1-to-1 compilation seemed a better fit.I see, so Remix has to do a lot of rewriting and custom building to spit out both a frontend and a backend out of the same JS code? If so, I can see it being finicky to Clojurescript compiled JavaScript.
Yes, exactly, and also building for different platforms. That's what I thought. Glad to get it confirmed by a more experienced Clojure dev 🙏