Subscribe on changes!

Transform files and intercept original calls to build ones

avatar
May 10th 2020

Is your feature request related to a problem? Please describe. After my last issue, I was eager to build a tool like vitebut without any resolver algorithms as it is already handled by the modern es spec and the importmap spec (trough polyfill for most browsers atm). But I was wondering how to resolve non-native files like Typescript, Vue or any other files that need to be pre-processed. I tried a proof-of-concept, here (available on npm too), that doesn't process the source code except for files which have a transformer available. They are placed in a special directory, and when the non-native files are requested, the request is intercepted to send the transformed build. But this use a Service Worker placed at the root of the user app (it's the only way for a SW to work), and it's not really sexy.

Describe the solution you'd like I would want to extend the "without bundler" concept to the build step, and try to extend vite so that it process only files that needs to be compiled to be understood by the browser and try to find a way to intercept the calls to files that have been transformed to serve the transformed one.

Additional context But I don't know if this is a good feature and in the scope of vite, so let me know if not.

avatar
May 10th 2020

This is something I have on the roadmap - a service worker that caches compiled files and avoid sending any unnecessary requests to the server.

avatar
May 12th 2020

I managed to use a different approach than the Service Worker, I use the import-map specification here https://github.com/nestarz/esdev. I will try to use vite as an inspiration and grow it in parallel.