[browser] Separate hybrid globalization JS code to es6 module
Contributes to https://github.com/dotnet/runtime/issues/98483.
- separate hybrid globalization JS code into a separate module
- add the module if
HybridGlobalization=true(temporarily for draft PR we're usingWasmEnableThreads)
When solved, is there a good way to read MsBuild's value and attach/remove module in the runtime? The ideal solution should avoid creating a new runtime flavor.
Sure. We will update GenerateWasmBootJson (and WasmAppBuilder for the time being) to either include the module or not, and update the loading in TS
Blazor-connected failures in WBT require changes to https://github.com/ilonatommy/aspnetcore/blob/3e168fe85e2330621ed12d9c9524c80e0f743dc6/src/Components/dotnet-runtime-js/dotnet.d.ts#L176 (adding jsModuleGlobalization).
Wasm.Build.Tests.Blazor.IcuTests.HybridWithInvariant(config: "Debug", invariant: False) [FAIL]
Could not find dotnet.globalization.js in bundle directory: C:\helix\work\workitem\e\wbt artifacts\blz_hybrid_Debug_4lfnum1h_dzk\bin\Debug\net9.0\wwwroot\_framework. Actual files on disk: dotnet.js, dotnet.js.map, dotnet.native.js, dotnet.native.wasm, dotnet.runtime.js, dotnet.runtime.js.map
Stack Trace:
/_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(176,0): at Wasm.Build.Tests.ProjectProviderBase.AssertDotNetFilesSet(IReadOnlySet`1 expected, IReadOnlyDictionary`2 superSet, IReadOnlyDictionary`2 actualReadOnly, Boolean expectFingerprintOnDotnetJs, String bundleDir)
/_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(158,0): at Wasm.Build.Tests.ProjectProviderBase.FindAndAssertDotnetFiles(String binFrameworkDir, Boolean expectFingerprintOnDotnetJs, IReadOnlyDictionary`2 superSet, IReadOnlySet`1 expected)
/_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(78,0): at Wasm.Build.Tests.ProjectProviderBase.FindAndAssertDotnetFiles(AssertBundleOptionsBase assertOptions)
/_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(44,0): at Wasm.Build.Tests.ProjectProviderBase.AssertBasicBundle(AssertBundleOptionsBase assertOptions)
/_/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs(83,0): at Wasm.Build.Tests.WasmSdkBasedProjectProvider.AssertBundle(AssertWasmSdkBundleOptions assertOptions)
/_/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmProjectProvider.cs(17,0): at Wasm.Build.Tests.BlazorWasmProjectProvider.AssertBundle(BlazorBuildOptions options)
/_/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs(128,0): at Wasm.Build.Tests.BlazorWasmTestBase.AssertBundle(String buildOutput, BlazorBuildOptions blazorBuildOptions)
/_/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs(67,0): at Wasm.Build.Tests.BlazorWasmTestBase.BlazorBuild(BlazorBuildOptions options, String[] extraArgs)
/_/src/mono/wasm/Wasm.Build.Tests/Blazor/IcuTests.cs(38,0): at Wasm.Build.Tests.Blazor.IcuTests.HybridWithInvariant(String config, Nullable`1 invariant)
--- End of stack trace from previous location ---
Blocked by flow of https://github.com/dotnet/aspnetcore/pull/55716 to runtime.
Blazor-connected failures in WBT require changes to https://github.com/ilonatommy/aspnetcore/blob/3e168fe85e2330621ed12d9c9524c80e0f743dc6/src/Components/dotnet-runtime-js/dotnet.d.ts#L176 (adding
jsModuleGlobalization).
I think that the blazor PR would not fix it because it's just type definition. The error is complaining about missing files. Likely flow of blazor with this change will fix it.
cc @maraf
Blazor-connected failures in WBT require changes to https://github.com/ilonatommy/aspnetcore/blob/3e168fe85e2330621ed12d9c9524c80e0f743dc6/src/Components/dotnet-runtime-js/dotnet.d.ts#L176 (adding
jsModuleGlobalization).Wasm.Build.Tests.Blazor.IcuTests.HybridWithInvariant(config: "Debug", invariant: False) [FAIL] Could not find dotnet.globalization.js in bundle directory: C:\helix\work\workitem\e\wbt artifacts\blz_hybrid_Debug_4lfnum1h_dzk\bin\Debug\net9.0\wwwroot\_framework. Actual files on disk: dotnet.js, dotnet.js.map, dotnet.native.js, dotnet.native.wasm, dotnet.runtime.js, dotnet.runtime.js.map Stack Trace: /_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(176,0): at Wasm.Build.Tests.ProjectProviderBase.AssertDotNetFilesSet(IReadOnlySet`1 expected, IReadOnlyDictionary`2 superSet, IReadOnlyDictionary`2 actualReadOnly, Boolean expectFingerprintOnDotnetJs, String bundleDir) /_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(158,0): at Wasm.Build.Tests.ProjectProviderBase.FindAndAssertDotnetFiles(String binFrameworkDir, Boolean expectFingerprintOnDotnetJs, IReadOnlyDictionary`2 superSet, IReadOnlySet`1 expected) /_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(78,0): at Wasm.Build.Tests.ProjectProviderBase.FindAndAssertDotnetFiles(AssertBundleOptionsBase assertOptions) /_/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs(44,0): at Wasm.Build.Tests.ProjectProviderBase.AssertBasicBundle(AssertBundleOptionsBase assertOptions) /_/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs(83,0): at Wasm.Build.Tests.WasmSdkBasedProjectProvider.AssertBundle(AssertWasmSdkBundleOptions assertOptions) /_/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmProjectProvider.cs(17,0): at Wasm.Build.Tests.BlazorWasmProjectProvider.AssertBundle(BlazorBuildOptions options) /_/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs(128,0): at Wasm.Build.Tests.BlazorWasmTestBase.AssertBundle(String buildOutput, BlazorBuildOptions blazorBuildOptions) /_/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs(67,0): at Wasm.Build.Tests.BlazorWasmTestBase.BlazorBuild(BlazorBuildOptions options, String[] extraArgs) /_/src/mono/wasm/Wasm.Build.Tests/Blazor/IcuTests.cs(38,0): at Wasm.Build.Tests.Blazor.IcuTests.HybridWithInvariant(String config, Nullable`1 invariant) --- End of stack trace from previous location ---Blocked by flow of https://github.com/dotnet/aspnetcore/pull/55716 to runtime.
This is just build setup error, isn't it? The globalization.js file is not copied to the output folder. Either the SDK doesn't correctly work or the WBT check isn't cotrect. There shouldn't be anything needed on blazor side to make it work.
The dotnet.d.ts in aspnetcore repo is only important for their build of their typescript that interact with runtime API.
This is just build setup error, isn't it? The globalization.js file is not copied to the output folder. Either the SDK doesn't correctly work or the WBT check isn't cotrect. There shouldn't be anything needed on blazor side to make it work.
The
dotnet.d.tsin aspnetcore repo is only important for their build of their typescript that interact with runtime API.
WBT works correctly (non-Blazor IcuTests pass). You're right, it fails because WBT expects the globalization module to be in the bundle when HybridGlobalization == true. Not sure if we can rely on the changes to flow and the problem to "fix itself" as Pavel mentioned.
However, even if the file was copied, we have no entry in blazor.boot.json about jsModuleGlobalization (added by this PR) that is needed to initialize the module loading. Again, no idea how to check if this will get fixed automatically.
/azp run runtime-wasm
Azure Pipelines successfully started running 1 pipeline(s).
/azp run runtime-wasm
Azure Pipelines successfully started running 1 pipeline(s).
Firefox failures are https://github.com/dotnet/runtime/issues/101617 (locally passes, it's only a CI problem), HybridGlobalization_AOT failures are: https://github.com/dotnet/runtime/issues/102373 - fails on main as well.