Vite + Esbuild Plugins #464
Replies: 2 comments 1 reply
-
@borkdude while exploring this more I realized that it would be great to be able to resolve CLJS namespaces from tools like Rollup or Vite. In order to do this reliably we would need a marker that can trigger the resolver: import * as my_ns from 'cljs-ns:com.app.namespace'; With something like this a custom Rollup resolver could be implemented: function namespaceResolve () {
return {
name: 'cljs-ns-resolve', // this name will show up in logs and errors
resolveId ( source ) {
console.log("source:", source)
if (source.startsWith("cljs-ns:")) {
return fileForNs(source)
}
return null; // other ids should be handled as usually
}
};
} esbuild supports similar resolver functionality. Maintaining plugins for esbuild, vite and rollup would be important & something I'm happy to help with! |
Beta Was this translation helpful? Give feedback.
-
There's now a plugin for Vite that is being published to NPM as well: https://github.com/squint-cljs/vite-plugin-squint |
Beta Was this translation helpful? Give feedback.
-
Hello!
Just wanted to share some super basic plugin code for
vite
andesbuild
that allows you to only run those tools and not worry about squint compilation:vite.config.js
build.js
(esbuild)I haven't done a ton of tire-kicking but it seems to work for my situation for now, including transpiling JSX to
React.createElement
calls.Let me know if you give it a try and run into issues!
Beta Was this translation helpful? Give feedback.
All reactions