evanw / evanw/esbuild

[FR] Allow FS override

Open
#4,537 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading api/api.go BuildOptions, api/api_impl.go rebuildImpl around line 1493, and internal/fs/fs.go including InMemoryOpenedFile. Compare the proposed full FS override with the cache-seeding and CacheOnly approach, including dependency discovery and cache-miss behavior; done means the supported behavior is defined and verified for bundling without unnecessary disk writes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.