Skip to content

[browser] Assembly search path should be relative to the blazor.boot.json, not the importing module. #99539

Open

Description

@onionhammer

Description

When finding .wasm files in detect_features_and_polyfill, the scriptUrlQuery variable is derived from the importing module (import.meta.url) instead of where the blazor.boot.json file is, and there does not appear to be any way to configure it to look in a different path.

This means that bundlers which generate a module which imports the dotnet runtime will struggle to put the generated module into a _framework folder alongside the rest of the .NET/wasm assets.

Reproduction Steps

Create a vite project, import a .NET wasm assembly based project, build the vite project.

Expected behavior

The default behavior for loading .wasm files should be that it loads from the same directory as the blazor.boot.json file, or else provide a configuration (ala ".withConfigSource()") which allows the caller to specify where the .wasm files are stored.

Actual behavior

the bundled javascript attempts to load the .wasm from whatever path it's currently on.

loader/polyfills.ts:42

image

without any possibility to configure where the assemblies actually are; i.e. "./" instead of "./_framework/*"

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. ghost added
    needs-area-label
    on Mar 11, 2024
  2. added
    untriaged
    on Mar 11, 2024
  3. removed
    needs-area-label
    on Mar 12, 2024
  4. maraf commented on Mar 13, 2024

    @maraf
    Member

    You have several workarounds at the moment

    • You can set <WasmRuntimeAssetsLocation>./</WasmRuntimeAssetsLocation> MSBuild property to skip putting wasm runtime assets to _framework folder.
    • You can use withResourceLoader to modify on runtime a location where it loads assets from.

    We are looking into making the wasm app structure more bundler friendly. Inlining boot config or #86162 are one of the things

  5. added this to the 9.0.0 milestone on Mar 13, 2024
  6. removed
    untriaged
    on Mar 13, 2024
  7. changed the title [-]WASM: Assembly search path should be relative to the blazor.boot.json, not the importing module.[/-] [+][browser] Assembly search path should be relative to the blazor.boot.json, not the importing module.[/+] on Apr 22, 2024
  8. modified the milestones: 9.0.0, 10.0.0 on Jul 24, 2024
  9. modified the milestones: 10.0.0, Future on Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-System.Runtime.InteropServices.JavaScriptos-browser

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions