Replies: 4 comments
-
Hi Eilon, thanks for your excellent work. But I tried compiling the And the version of |
Beta Was this translation helpful? Give feedback.
-
Just wanted to chip in and say it affects iOS devices too. I've had several complaints about issues on older iPhones such as the iPhone 7. |
Beta Was this translation helpful? Give feedback.
-
same problem, the workaround worked |
Beta Was this translation helpful? Give feedback.
-
This worked perfectly! Thank you so much!! |
Beta Was this translation helpful? Give feedback.
-
I've published a workaround for supporting Blazor Hybrid on older Android devices that have older WebView components. Those older WebViews support only older JavaScript versions, and are incompatible with the latest Blazor Hybrid scripts.
Here are some of the reports of this issue:
Uncaught SyntaxError: Unexpected token .
aspnetcore#53699The problem and the fix
The official version in .NET 9 has code that targets ES2022, which can produce JavaScript code that is not compatible with older Android devices. The suggestion was to target ES2019, which is compatible with older devices. One of the suggestions in those issues was to compile the
blazor.webview.js
file (which is written in TypeScript) to target that older EcmaScript (ES) version.The fix I made was to change the build of the
blazor.webview.js
file to use ES2019. To do that I changed these two versions fromES2022
toES2019
: https://github.com/dotnet/aspnetcore/blob/ecfaab9e762b14e35fc29fe2799ca458a057c14f/src/Components/Shared.JS/tsconfig.json#L3-L5And then I produced a local build of the
blazor.webview.js
JavaScript file, and included it in my .NET MAUI Blazor Hybrid app. And it worked!How to apply the fix to your app
To use the new ES2019-compatible script I followed these steps:
wwwroot\scripts
wwwroot\index.html
and at the bottom of that file change this line:And that's it!
How I tested the fix
For informational purposes, here's what I used to confirm the original bug reproduces, and then verify the fixed version.
Beta Was this translation helpful? Give feedback.
All reactions