Uncaught SyntaxError: import.meta may only appear in a module
See original GitHub issueWhen a server-client project created from the Bolero template (latest) is updated from net6.0 to net7.0, the following error appears in browsers. The Bolero page is also blank, except for the dark Bulma bar with logo at the top which is served by the server-side early, I believe before WebAssembly kicks in.
Firefox: Uncaught SyntaxError: import.meta may only appear in a module source: dotnet.7.0.0.amub20uvka.js
Chrome and Edge: Uncaught SyntaxError: Cannot use ‘import.meta’ outside a module source: some other js-file with a cryptic name
It’s actually the same error, just with slightly different wording, and Firefox is also kind enough to hint about the platform version, which is important here.
How to reproduce:
Run the following web application generated with the latest Bolero template in Visual Studio 17.4.0, currently latest. Also fails in latest Preview version.
Note that the page is blank, except for the dark Bulma bar with logo at the top.
In a Firefox browser, inspect the page errors using the browser’s developer tools. Note that the name of the failing file indicates this is dotnet7.0.0
To verify that it works with net6.0, change the target in the client to net6.0. That’s all that is needed for success, though the Microsoft assembly can also be downgraded for good measure. Now run with Firefox again, and note that now there is a javascript file name containing dotnet6.0.11, or whichever version of 6.0.x is on the machine.
Observed on two out of two developer machines so far.
This is a continuation of the problem solving in https://github.com/fsbolero/Bolero/issues/279, related to updating to .NET 7. This is a second issue. The first issue was resolved through the use of ProduceReferenceAssembly
with value false
in client project files.
Additional information. These two log files are the outputs from the console when running net6 and net7. I am not much of an expert here, but I’m guessing there’s not much to gain from studying these, except that net7 doesn’t deliver the missing content.
Of course you can test with browsers other than Firefox, but you’ll miss the nice version indication in the WebAssembly javascript filename.
Issue Analytics
- State:
- Created 10 months ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
Bolero 0.21.25 should now be working without an explicit dependency on Microsoft.AspNetCore.Components.WebAssembly.
There is now an explicit reference to Microsoft.AspNetCore.Components.WebAssembly 7.0.* in v0.21 of the project template.