Blazor Dependencies

Denis Kotov
1 min readJul 29, 2020

Blazor is the modern framework for writing SPA applications in C#

https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor

But as a new technologies there are some issues …

Consider you want to create NiceLayout Razor Class Library (reusable parts of UI, like React Components) that depends on MatBlazor

But MatBlazor has dependencies on the following files:

Of course you can specify in your documentation that when you use NiceLayout customer should also include dependencies above …

But what if you created custom layout based on MatBlazor and Radzen component libraries and Radzen also has dependencies to another library ?

User will have to include bunch of dependencies about which it even do not know !!

BlazorDependencies is JavaScript Library that helps maintain dependencies with simple wwwroot/blazorDeps.json which describe dependencies of your component:

Then user of you library should create wwwroot/blazorDeps.json with following dependency:

And change wwwroot/index.html like that:

JavaScript will search blazorDeps.json recursively in each Razor Class Library

Maintenance of dependencies become much easier because you just need to specify in wwwroot/blazorDeps.json libraries (library should also use wwwroot/blazorDeps.json) and blazor.dependencies.js will recursively add in wwwroot/index.html all dependencies and transitive dependencies ;)

--

--