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

[Blazor] Have a way to configure dotnet runtime for blazor apps #49264

Closed
maraf opened this issue Jul 7, 2023 · 11 comments · Fixed by #49420
Closed

[Blazor] Have a way to configure dotnet runtime for blazor apps #49264

maraf opened this issue Jul 7, 2023 · 11 comments · Fixed by #49420
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Milestone

Comments

@maraf
Copy link
Member

maraf commented Jul 7, 2023

Current JavaScript runtime API allows to configure various parameters. We should have a way to allow Blazor users to leverage them.

Some of the features are currently configurable through MSBuild (and boot config).

Should we allow Blazor users to interact with JavaScript runtime API directly? aka make dotnet builder visible on Blazor JavaScript api?
Should we have MSBuild (and boot config) alternative for every configuration that is possible in JavaScript api?

@maraf maraf added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Jul 7, 2023
@maraf
Copy link
Member Author

maraf commented Jul 7, 2023

@pavelsavara
Copy link
Member

I prefer JS API

@javiercn
Copy link
Member

javiercn commented Jul 7, 2023

@maraf do we have a list?

@pavelsavara
Copy link
Member

We have the API, I don't want to duplicate that API as msbuild properties.

@maraf
Copy link
Member Author

maraf commented Jul 10, 2023

@maraf do we have a list?

It's not a complete list, but it includes. For some of them we already have MSBuild properties/items.

We have the API, I don't want to duplicate that API as msbuild properties.

I think that for vanilla wasm app, it's okay to configure the runtime in JS, because you have to deal with the runtime JS anyway. In Blazor, users typically don't have deal with the platform startup. In general I would say that having an MSBuild way to define "everything" that is in the MonoConfig/MonoConfigInternal is benefitial.

@pavelsavara
Copy link
Member

In Blazor, users typically don't have deal with the platform startup.

Fair point

@javiercn
Copy link
Member

@maraf what would entail to expose whatever is needed to configure the underlying runtime.

Would that be a callback users can register in BlazorWebAssemblyStartOptions? (for example).

@maraf
Copy link
Member Author

maraf commented Jul 11, 2023

@javiercn Yes, to modifying runtime options

export interface WebAssemblyStartOptions {
  loadBootResource(type: WebAssemblyBootResourceType, name: string, defaultUri: string, integrity: string): string | Promise<Response> | null | undefined;
  environment?: string;
  applicationCulture?: string;
+  configureRuntime(builder: DotnetHostBuilder): void;
}

Second part to that is exposing running instance API, so that users can call setModuleImports, getAssemblyExports, etc

export const Blazor: IBlazor = {
  navigateTo,
  registerCustomEventType,
  rootComponents: RootComponentsFunctions,
+  runtime: RuntimeAPI,

  _internal: {
    navigationManager: navigationManagerInternalFunctions,
    domWrapper: domFunctions,
    Virtualize,
    PageTitle,
    InputFile,
    NavigationLock,
    getJSDataStreamChunk: getNextChunk,
    attachWebRendererInterop,
  },
};

@pavelsavara Blazor users can't use JSImport/JSExport currently, because there is not way to set imports or get exports, right?

@pavelsavara
Copy link
Member

they could use JSImport with ES6 module.

They could also obtain the runtime by globalThis.getDotnetRuntime(0) for both export/import, that's what we documented.

Adding runtime to IBlazor is better. 👍

Note: globalThis.Blazor is singleton. Meaning you can't have multiple runtimes/blazors right now.

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jul 11, 2023
@mkArtakMSFT mkArtakMSFT added this to the 8.0-rc1 milestone Jul 11, 2023
@mkArtakMSFT
Copy link
Member

@maraf is this resolved by #49385 ?

@maraf
Copy link
Member Author

maraf commented Jul 14, 2023

No, I'll file a separate PR

@ghost ghost locked as resolved and limited conversation to collaborators Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants