Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can esbuild support go:embed? #3288

Closed
par5er opened this issue Aug 5, 2023 · 1 comment
Closed

Can esbuild support go:embed? #3288

par5er opened this issue Aug 5, 2023 · 1 comment

Comments

@par5er
Copy link

par5er commented Aug 5, 2023

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/*
var myFs embed.FS

api.Build(api.BuildOptions{
  WorkingDir: myFs, // WorkingDir would accept a "io/fs".FS (defaulting to os.DirFs(<working directory>))

  // Other options would stay the same
  EntryPoints: []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!

@evanw
Copy link
Owner

evanw commented Aug 6, 2023

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.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants