squint 2024-10-27

Squint browser REPL progress :)

🎉 16

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

Thats the vite plugin now?

Or how did you accomplished that

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;
    });
  }
};

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

❤️ 1

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

Can this be used to achieve REPL for JS also?

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

I guess i'll stick to hot reload.

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