Skip to content

Lazy loaded BlazorCustomElements.js file does not adhere to the loadBootResource configuration #45104

@martinlingstuyl

Description

@martinlingstuyl

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi guys,

Since .NET 7 is out, I've been test driving Blazor WASM to see how to use it in combination with other frameworks.

I've configured the following to be able to point the loading of resources to a specific server.
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-7.0#load-boot-resources

Which works nicely.

I'm now using the Microsoft.AspNetCore.Components.CustomElements nuget package to get CustomElements to work.
Initially you had to reference the script manually:

<script src="_content/Microsoft.AspNetCore.Components.CustomElements/BlazorCustomElements.js"></script>

But since .NET 7 has been released it's lazy loaded by ASP.NET. Which is awesome. The only problem is: it uses the URL of the server you are on, to lazy load the file, while it should be respecting the loadBootResource configuration.

Which is a problem for me, as I'm depending on the loadBootResource function to get the WASM files from another server, for example a CDN.

Is that something you guys can fix?

cc: @guardrex dotnet/AspNetCore.Docs#27638

Expected Behavior

Loading the JS for CustomElements should respect the loadBootResource configuration.

Steps To Reproduce

  1. Create a Blazor WASM client app
  2. Create a simple webserver that loads the Blazor script with autostart="false" and add the following bootstrapping lines:
Blazor.start({
        loadBootResource: function (type, name, defaultUri, integrity) {
          return 'https://localhost:8088/' + defaultUri`;
        }
      });
  1. Install the CustomElements nuget and implement a basic customelement.
  2. Try loading the basic webserver with the customelement and blazor script.

Exceptions (if any)

No response

.NET Version

7

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-js-root-componentsIssues related to JS root components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions