[FR] Allow FS override
Hi, I am building a native solidjs templating library for Go, see github.com/lilybw/go-solid For me, it would be very valuable being able to skip the step of having to write contents to disk before then directing esbuild read from there (I am able to do most things in mem at the moment). This however, would probably need as the title suggest: A way to override the current file system access.
I can see that you already allow files to be opened in memory internally (internal/fs/fs.go#InMemoryOpenedFile) - probably for testing I recon - and thats about what I should like to do too. I am aware of the consequences this might have in terms of dependency discovery and such - my scenario just so happens to be the one where it makes a lot of sense.
Solution A: Full FS Override: Move fs/fs.go#FS out of internal, or use interface composition to allow a public variant with a subset of methods.
Make a field for the consumer impl in api/api.go#BuildOptions Allow the override to take the place at: api/api_impl.go#rebuildImpl@L1493
Done.
Solution B: Cache seeding and no-disk FS implementation Allow a cache to be provided, and an option to use an FS implementation that doesnt reach disk. "CacheOnly bool" or smth. Bundling will then understandably fail on any cache miss.
Hope you will concider adding any of this flexibility, it would let me avoid so many unnecessary operations and points of failure.
Source: evanw/esbuild