Fork me on GitHub
#squint
<
2024-02-12
>
martinklepsch13:02:12

Did anyone make a webpack loader for squint? 🙂 Based on this it looks like it might not be too hard? https://github.com/webpack-contrib/coffee-loader/

borkdude13:02:46

not sure if that's the way to go though, just running the squint compiller and using vite on top of that is my favorite workflow right now

martinklepsch13:02:34

whats the best example of that I could look at? Maybe it also works for my use case too

martinklepsch14:02:49

Cool! FYI, it's super trivial to just let vite to the compiling:

import { defineConfig } from "vite";
import preact from "@preact/preset-vite";
import { compileString } from "squint-cljs";

// 
export default defineConfig({
  plugins: [
    preact(),
    {
      name: "squint_compile",
      transform: function (src, id) {
        // compile cljs files to js
        if (/\.cljs$/.test(id)) {
          var js = compileString(src);
          return { code: js, map: null };
        }
      },
    },
  ],
});

👍 1
👀 2
martinklepsch14:02:36

I feel like this is slightly more elegant than running the squint compiler in a separate process?

borkdude14:02:41

perhaps, I don't know what you will run into with this approach :)

martinklepsch15:02:03

yeah, i wonder how it works with transitive stuff

borkdude15:02:15

the squint CLI doesn't care about transitive stuff at the moment, it just compiles the file that changed, that's it

borkdude15:02:30

then the vite plugin will do the hot-reloading based on the compiled .js files

martinklepsch19:02:42

I might look into this a bit more, I think a first class integration with something like Vite would be cool!

☝️ 1