-
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
URL assets bundling #795
Comments
@edoardocavazza you might want to take a look at #312. |
Does any bundler currently do this? What would be the semantics specifically? Would this require the loader to be |
Not the OP, but I'd love to see something like Webpack@5 Asset Modules. The specific behaviour that I think would be a great fit is the following:
Benefits:
Really excited to see where you land on this @evanw. |
It seems weird to me that the bundler would replace an object with a string. Then e.g. |
Excellent point. That doesn't work at all. I wonder if the same behaviour, but without the substitution would work? Edit: or perhaps only the first argument of the |
Actually, on my side, I would be really happy to have a way to retrieve the 'pre-bundled' |
Adding a +1 to this request, but also wanted to share an example of how the Rollup plugin does this that may address your https://modern-web.dev/docs/building/rollup-plugin-import-meta-assets/ If you look at the plugin itself it's incredibly simple and leans on Rollup's own asset output functionality, but I think the key thing it does is return a modified (FWIW I do think this is how webpack 5 does this as well — it returns a modified I was actually gonna submit a separate issue on whether |
I now see that Rollup plugin was what was linked in the original issue. 😶 Sorry @edoardocavazza! |
@evanw do you think this might offer a viable path forward for introducing 'arbitrary' code split boundaries? |
It seems similar to two existing features in esbuild. One of those is the |
I think we're thinking the same thing then but perhaps I haven't done a good job articulating it. I don't think 'arbitrary' was a good word choice. Calling out the parallels to the I'm looking forward to being able to use something like this for frictionless web-worker bundling. |
This would be invaluable for web workers (#312), and would personally save me a lot of debugging time and pain. At this point, it's impossible to use As someone familiar with JS and Go but who hasn't contributed, what could someone do to help move this forward? |
Okay, matching the appropriate syntax in the AST wasn't too bad: master...lgarron:new-url-entry I'm having some trouble adding it to the import graph, as I don't fully understand
master...lgarron:new-url-entry-import-graph is as far as I've gotten so far. |
based on @lgarron work (as I have zero Golang experience) here is a demo of: const workerEntryFileURL = new URL("./worker.test.js", import.meta.url);
new Worker(workerEntryFileURL, { type: "module" }); being converted into: var workerEntryFileURL = new URL("./worker.test-P7GTNY24.js");
new Worker(workerEntryFileURL, { type: "module" }); The entry is handled exactly like a dynamic import ( |
😍 I was able to use this locally, with a few issues:
|
My use case is static site generation: The same code has to run on the client and in Node.js. And currently If the asset files are copied next to the bundle, then the code can remain unchanged. If the files are renamed (e.g. to append digest strings), then only the first argument of More information on associating assets: https://web.dev/bundling-non-js-resources/ |
I'm planning on releasing a form of this sometime soon. You can see my work in progress version here: #2508. This will initially require code splitting to be enabled (as well as bundling and ESM output of course) as esbuild's internals currently mean each input module only shows up in one output file. It will also require paths to be explicitly relative (i.e. start with |
I think it would be great.
Since we are using the |
Two reasons why I was thinking explicitly relative could be a good way to start:
|
I just investigated what Webpack/Parcel/Rollup do for this feature:
So perhaps I should allow omitting the I also need to finalize what |
I’d start with minimal functionality and see where it goes. My feeling is that how URLs work should stay as close to uncompiled code as possible, which would indeed mean only |
Plain |
Plain |
I'm currently evaluating esbuild, and I'm wondering if it was decided whether the upcoming functionality would bundle or copy the referenced assets. For my particular use case, I'm importing Workers. The code in the Worker does further imports so it would definitely be beneficial for me to bundle instead of copy, but that's just my 2 cents. I'm excited to see this getting close to release as it would be nice to be able to drop my old build system in favor of esbuild. |
As soon as `esbuild` supports `new URL(…, import.meta.url)` (evanw/esbuild#795), I want to include a tiny bit of Rust WASM in the published library to see how much of the ecosystem can handle it.
Hi, this is super important for ES6 modules compiled with Emscripten which use It is important to be able to copy the asset in this case to benefit from streaming WebAssembly compilation and compression, among other things. It would be super nice if esbuild supported this directly like webpack does. |
As I understand it, Netlify (CLI) leverages esbuild for bundling functions, so seeing support for this would be great for Netlify users (like myself) too. 😊 |
To add some context, since I had to investigate this in my day job:
Rollup indeed does not consume URL assets, but it does produce code that uses it. If a plugin outputs |
I encountered this issue while working on a library that exposes a back-end middleware that is able to serve static assets (including JS files) to the front-end. In my use case, I first bundle the front-end JS (& css), then reference the bundled files from the back-end This seems to be consistent with what webpack & @web/rollup-plugin-import-meta-assets do, and is something I would like to be able to do with esbuild. I am mentioning this because it is simpler to treat all files referenced by |
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Neuroglancer can now be used as a regular NPM dependency with vite, parcel, or webpack as the bundler (but unfortunately not esbuild due to evanw/esbuild#795), and can be installed as a dependency via a git URL. Node.js import/export conditions are now used to enable/disable layer types and datasources, which can be configured by dependent projects rather than when Neuroglancer itself is built/published. The Python tests accept a `--build-client` option to run the dev server automatically rather than requiring a pre-built Python Neuroglancer client.
Any update that on that @evanw? |
Hello!
Is there any plan to support assets bundling using the URL constructor and import.meta?
Something like this:
would be equivalent to:
but with native browser support.
This is how we can do that with rollup https://modern-web.dev/docs/building/rollup-plugin-import-meta-assets/. I think it could fit with the "convention over configuration" policy of esbuild.
The text was updated successfully, but these errors were encountered: