dotnet / dotnet/aspnetcore

Provide an easier way to import component specific scripts

Open
#61,684 2 comments 5 reactions 0 assignees View on GitHub
area-blazor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

Currently, to load a component specific script (.razor.js) you do something like this:

```csharp
module = await JS.InvokeAsync("import", "./{PATH}/JsCollocation2.razor.js");
```

The `"import"` convention is a bit awkward to remember and you also need specify the script path. Could we make this simpler? Maybe provide an ImportAsync overload? Or maybe a declarative model, like this (suggestion from @DamianEdwards)?:

```csharp
[JsModuleImport]
private IJSObjectReference? Module { get; set; }
```

@MackinnonBuck did some prototyping for component specific styles that work across render modes a while back that might also be worth considering: [MackinnonBuck/blazor-js-components](https://github.com/MackinnonBuck/blazor-js-components)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.