Replies: 5 comments 6 replies
-
Generally I would strongly advise against doing this. It is rarely a good idea to run the build output of one tool through another. The chances of things going wrong are rather high. A slightly more recommended way would to use :js-provider :external. If you insist on doing this I cannot help you much, since I do not know about the vite side of things. I can clear up some confusion though.
I suspect that the reason you are not seeing compile errors is that the websocket just plainly fails to begin with. Using vite will mean that certain features will either be broken or just unavailable, there isn't much that can be done about that. If the websocket is actually working it might also be that shadow-cljs actually tries to show the HUD, but vite then immediately destroys it via its hot-reload, potentially because it did an actual full page reload? The console should tell you what is going on. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer! I think this is what happening:
And you are right, having two bundlers compete against each other is rather unwanted. The issue with "external" is that as far as i see, that only target allowed is "browser", which then creates a main.js script and a CommonJS external file. Loading the main script with defer and the external JS as module, does not work as expected. |
Beta Was this translation helpful? Give feedback.
-
Ah sorry i forget about the :external-index-format :esm option. But i think also when i was setting it up, i hadn't found a solution for the shadowBridge not defined issue beside setting the js-provider to "import and using ESM as target. I have to get into all the options again and see if i can figure it out. |
Beta Was this translation helpful? Give feedback.
-
I think, you are right and having Vite compete with shadow is just a bad idea. Vite has some nice features that would have been handy to have. I found this great blog post by Metosin ( which wasn't published, when i started setting up our project ). Which does what you are recommending and solves it using shadow and esbuild. Thank you for your help! |
Beta Was this translation helpful? Give feedback.
-
Ah yes that sounds reasonable.
Hehe yeah true, we used the proxy to forward some auto translations which is only possible and needed in dev mode. But its not so important, so we drop it. Was just convenient, that it is possible to do it in Vite. So now everything goes through the backend server again. |
Beta Was this translation helpful? Give feedback.
-
Hi There
We are trying to combine shadowcljs with vite.
Basically shadowcljs should compile all cljs sources to esm and vite should pick that up in conjunction with all the js/tsx/jsx files in the project, then reloading everything in the dev server ( or later build the final release ).
This works in a way at the moment, but there are some issues we are encountering.
HMR of course does not work correctly, since shadow creates one big main.js that gets reloaded.
But the bigger problem is, that compile errors in the HUD of shadow get discarded by vite, since those get injected by shadow into the dom, which vite is not aware of.
Maybe i'am overseeing something, and there is a easy way to access the compile errors and insert them somehow in the lifecycle of vite? Or something is not configured correctly?
Has somebody experience with this kind of setup?
For reference here the shadowcljs config:
Beta Was this translation helpful? Give feedback.
All reactions