exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework
https://ultrajs.dev
MIT License
2.99k stars 66 forks source link

feat: add compile hooks to dev server #198

Closed b3nten closed 1 year ago

b3nten commented 1 year ago

Adds compile hooks to the compiler middleware of the dev server.

deckchairlabs commented 1 year ago

Sorry benten, still thinking about this. What's your exact use case?

b3nten commented 1 year ago

I wrote a compiler that parses source code and removes server code from client bundles. Without the ability to intercept the code before it hits SWC I'd be forced to make a copy of the entire project, apply the transforms, and then point Ultra to this duplicated project. And this would happen on every single save, so I'd have to write a custom file watcher etc. It's almost untenable. Would probably be easier to monkey-patch the dev server, but that's obviously not ideal when it could be supported natively in Ultra.

Exposing these hooks would be very useful for more than just this usecase - it gives devs the freedom to build on top of Ultra. Would be willing to chat about alternatives for my usecase though.

Edit: It's not a build step! I promise 😅

deckchairlabs commented 1 year ago

I'm thinking that we should parse before transform, so you can manipulate the AST before it's handed to transform