Skip to content

Commit

Permalink
Workaround for problem with blazor.extensions.signalr.js asset not lo…
Browse files Browse the repository at this point in the history
…aded after update to 3.1.0-preview4.19579.2 (lead to error: Could not find 'BlazorExtensions' in 'window'. Error: Could not find 'BlazorExtensions' in 'window'). See BlazorExtensions#66 for more details.
  • Loading branch information
Krzysztof Łaz committed Dec 12, 2019
1 parent c72b906 commit ad29015
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.1.100-preview3-014645"
"version": "3.1.100"
}
}
1 change: 1 addition & 0 deletions src/Blazor.Extensions.SignalR.JS/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/wwwroot/blazor.extensions.signalr.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<OutputType>Library</OutputType>
<IsPackable>false</IsPackable>
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<DefaultItemExcludes>${DefaultItemExcludes};dist\**;node_modules\**</DefaultItemExcludes>
<DefaultItemExcludes>${DefaultItemExcludes};node_modules\**</DefaultItemExcludes>
<NoWarn>CS2008</NoWarn>

<!-- VS's FastUpToDateCheck doesn't consider .ts file changes, so it's necessary to disable it to get incremental builds to work correctly (albeit not as fast as if FastUpToDateCheck did work for them) -->
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
<WebpackInputs Include="**\*.ts" Exclude="wwwroot\**;node_modules\**" />
</ItemGroup>

<Target Name="EnsureNpmRestored" Condition="!Exists('node_modules')">
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec Command="npm install" />
</Target>

<Target Name="RunWebpack" AfterTargets="ResolveReferences" Inputs="@(WebpackInputs)" Outputs="dist\blazor.extensions.signalr.js" DependsOnTargets="EnsureNpmRestored">
<RemoveDir Directories="dist" />
<Target Name="RunWebpack" AfterTargets="ResolveReferences" Inputs="@(WebpackInputs)" Outputs="wwwroot\blazor.extensions.signalr.js" DependsOnTargets="EnsureNpmRestored">
<RemoveDir Directories="wwwroot" />
<Exec Command="npm run build" />
<ItemGroup>
<EmbeddedResource Include="dist\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
<!--
<EmbeddedResource Include="wwwroot\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
-->
</ItemGroup>
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/Blazor.Extensions.SignalR.JS/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
"blazor.extensions.signalr": "./src/InitializeSignalR.ts"
},
output: {
path: path.join(__dirname, "/dist"),
path: path.join(__dirname, "/wwwroot"),
filename: "[name].js"
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<IsPackable>true</IsPackable>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
Expand All @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
Expand All @@ -10,8 +10,8 @@
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview3.19555.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview4.19579.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview4.19579.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />
<script src="_content/Blazor.Extensions.SignalR.JS/blazor.extensions.signalr.js"></script>
</head>
<body>
<app>Loading...</app>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.1.0-preview4.19579.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions test/Blazor.Extensions.SignalR.Test.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseAuthentication();
app.UseAuthorization();

app.UseStaticFiles();
app.UseClientSideBlazorFiles<Client.Startup>();

app.UseEndpoints(endpoints =>
Expand Down

0 comments on commit ad29015

Please sign in to comment.