-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Browser Build/Bundle API #527
Comments
That's a good idea. It should be possible to do this now that plugins exist. I'll work on this at some point. |
Hi @evanw, I've begun hacking on an idea and find myself wishing this sort of thing were possible both in the browser environment and other environments like a CloudFlare worker. Even in Node, I find myself wishing that the plugin api's reach was a little bit further. Specifically, I would like to run I would like to leverage I've found myself coming up against a few rough edges, notably:
Ideas
All this being said, I've found work-arounds for everything and it's really AMAZING what can be done so easily :D Thank you again for all your work. |
Paths in error messages and the metafile are relative to the current working directory.
Yup, makes sense. I think this is probably just an oversight.
I've thought about this before but there's an issue I would need to solve. Someone else filed this too: #546. I wrote some more thoughts over there.
I'll consider this. It would be a very different structure though since JSON doesn't have non-string keys. So it'd be a big breaking change.
I will consider this. It would indeed be a lot of overhead. It would also not work with other plugins, which could still access the file system anyway, so it wouldn't be a general-purpose mechanism. FWIW with the plugin system you should be able to avoid all of esbuild's behavior that's specific to the file system by just not working in the |
Maybe instead of changing the keys, new properties can be added so that entries look like this: {
"inputs": {
"velcro:https://cdn.jsdelivr.net/npm/[email protected]/index.js": {
+ "filename": "https://cdn.jsdelivr.net/npm/[email protected]/index.js",
+ "namespace": "velcro",
"bytes": 2108,
"imports": []
}
} That should be enough to break the ambiguity from the perspective of a consumer of the |
As you explore what the plugin API might look like in Specifically, I'm thinking about A related thought is that I'd love to see a method exposed via the plugin handler function argument that lets us invoke such logic (acknowledging the cost of the extra message passing). I can understand the perspective on the overhead of all this back-and-forth but believe that even in pathological cases, |
@evanw another challenge with the stdin API is that we can't inject multiple entrypoints. This would be really helpful for projects whose files are not coming from disk. |
This has been fixed in version 0.8.21. |
Hey Evan, amazing work with esbuild so far.
I noticed the build/bundle API is not supported in the browser via
esbuild-wasm
, however now with plugins it seems like it could be something that devs could work around. For example,import foo from 'some-module'
, if it's not marked external, would expect plugins to resolve and loadsome-module
, if that fails, then it can emit an error. Same for relative paths, which could be stored in memory rather than on disk.In many cases a plugin would just need to replace
'some-module'
with an unpkg prefixed URL and the build will still work.These changes should allow tools like the Svelte REPL to be built on top of esbuild, which can support "files" (in-memory), URL imports, and bare imports (resolved via unpkg or similar).
https://svelte.dev/repl
The text was updated successfully, but these errors were encountered: