You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to compile javascript on the fly (to serve request-specific JS) and I compile/minify code on every request (it's cached, don't worry!).
A good amount of time is spent reading files from disk so I want to use //go:embed to embed the code directly into my binary, to avoid costly I/O. Could esbuild support virtual file systems? Something like:
//go:embed web/*varmyFs embed.FSapi.Build(api.BuildOptions{
WorkingDir: myFs, // WorkingDir would accept a "io/fs".FS (defaulting to os.DirFs(<working directory>))// Other options would stay the sameEntryPoints: []string{"./src/index.tsx"},
Bundle: true,
Write: false,
...
})
This would also simplify deployments, as you can just package a single binary instead of carrying JS code around separately.
To be honest, I really can't think of a use-case outside my own. But I bet there are other places this can be useful. I can raise a PR if this is approved.
PS: Thanks for the library. You rock!
The text was updated successfully, but these errors were encountered:
I'm closing this issue as a duplicate of #690. I'm not going to add a Go-only interface such as io/fs.FS. If a file system interface is added to the API, it will be added with JS in mind and then an equivalent API will be exposed to Go.
I'm trying to compile javascript on the fly (to serve request-specific JS) and I compile/minify code on every request (it's cached, don't worry!).
A good amount of time is spent reading files from disk so I want to use
//go:embed
to embed the code directly into my binary, to avoid costly I/O. Could esbuild support virtual file systems? Something like:This would also simplify deployments, as you can just package a single binary instead of carrying JS code around separately.
To be honest, I really can't think of a use-case outside my own. But I bet there are other places this can be useful. I can raise a PR if this is approved.
PS: Thanks for the library. You rock!
The text was updated successfully, but these errors were encountered: