Blazor components support CSS bundling and cohesiveness: Foo.razor would have Foo.css, which will: a) enjoy CSS isolation; b) bundle into {ASSEMBLY NAME}.styles.css.

What I’m after is a similar mechanism for component-scoped JavaScript.

I don’t want to put generic functions in the global scope (window) and call them via jsComponentInitializers as demonstrated here, mainly because it breaks the idea of components as cohesive units; and also since if I put my JavaScript code within the .razor file, I end up having the same code repeated and scattered throughout the page, as I use multiple instances of that component.

The rendering mode is server-side rendering (SSR).

Is there a way to use JavaScript in a custom Blazor component such that it bundles into something similar to {ASSEMBLY NAME}.scripts.js, or any other form, and exists only once? (note that I still want to be able to distinguish between component instances in a similar way to the way CSS is component-isolated)