squint

borkdude 2024-10-27T16:54:23.609009Z

Squint browser REPL progress :)

🎉 16
teodorlu 2024-10-27T16:57:00.298779Z

At first I was like > What is this strange syntax, is :21 some kind of weird keyword??? 🤔 🤔 🤔 Before realizing that this is actually perfectly valid JSON! 😂

😄 1
borkdude 2024-10-27T16:57:22.463669Z

lol

m3tti 2024-10-27T17:05:09.237389Z

Thats the vite plugin now?

m3tti 2024-10-27T17:05:20.139269Z

Or how did you accomplished that

borkdude 2024-10-27T17:28:17.881849Z

I made a custom endpoint as a vite plugin that resolves deps to local files. Then I redirect to the vite @fs endpoint:

const ResolveDepsPlugin = {
  name: 'resolve-deps',
  async configureServer(server) {
    server.middlewares.use('/@resolve-deps', async (req, res, next) => {
      const url = req.url.substring(1);
      var file;
      try {
        file = await server.moduleGraph.resolveId(url);
      }
      catch (e) {
        res.writeHead(404);
        res.end();
        return;
      }
      console.log('url', url, 'file', file);
      const newUrl = `/@fs${file.id}`;
        res.writeHead(302, {
          location: newUrl,
        });
        res.end();
        return;
    });
  }
};

borkdude 2024-10-27T17:28:48.085999Z

and then I rewrite all imports to have a prefix with /@resolve-deps

❤️ 1
lemuel 2024-10-27T17:29:16.314699Z

This is the thing that’s excited me the most about Squint. I work with JS every day and haven’t found a good way to connect my editor to the browser. We’re so close to JS with Squint and get the lispy goodness

💯 3
Lari Saukkonen 2024-10-27T17:49:01.626139Z

Can this be used to achieve REPL for JS also?

m3tti 2024-10-27T18:10:04.763899Z

And here i sit and think about how i can do the same for borkweb

m3tti 2024-10-27T18:10:24.308699Z

I guess i'll stick to hot reload.

m3tti 2024-10-27T18:10:52.285789Z

Maybe eval might help or Function to get live reloading of cljs scripts