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

Include javascript files associated with Blazor components when using MapStaticAssets #59038

Open
1 task done
jofford opened this issue Nov 18, 2024 · 2 comments
Open
1 task done
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.

Comments

@jofford
Copy link

jofford commented Nov 18, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I noticed that javascript files associated with Blazor components are not being included as static assets in .NET 9 after calling MapStaticAssets(). It'd be great to get these automatically fingerprinted with an immutable cache-control as well. Loving static assets otherwise!

I generally locate javascript files associated with Blazor components in the same folder and load the module as follows.
module = await js.InvokeAsync<IJSObjectReference>("import", "./_content/MyRazorComponentLibrary/Components/MyComponent.razor.js")

I tried simply moving MyComponent.razor.js to "wwwroot\js" and loading the module from there however I then ran into the following error.
error BLAZOR106: The JS module file '----\wwwroot\js\MyComponent.razor.js' was defined but no associated razor component or view was found for it.

Describe the solution you'd like

Automatically include all javascript files associated with Blazor components as static assets by default

Additional context

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Nov 18, 2024
@javiercn
Copy link
Member

@javiercn javiercn added the bug This issue describes a behavior which is not expected - a bug. label Nov 19, 2024
@javiercn javiercn added this to the .NET 10 Planning milestone Nov 19, 2024
@andrewrauber
Copy link

@javiercn
This is causing us major problems with stale scripts.
Is there a way to work around this while we wait for a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

3 participants