invoke_ functions exported but exceptions and longjmp are both disabled

I’m developing a test project with .NET 8 browser-wasm template (wasm-tools workload) which uses Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.win-x64. I’ve been experimenting with getting SDL2 working in the browser which I have successfully managed by following these projects:

SDL2 works on its own but as soon as I try using Image, Mixer or TTF I run into problems. Here is my project file of the working SDL2 example:

<PropertyGroup>
	<TargetFramework>net8.0</TargetFramework>
	<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
	<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
	<WasmCachePath>$(MSBuildProjectDirectory)\wasm-cache</WasmCachePath>
	<WasmAllowUndefinedSymbols>true</WasmAllowUndefinedSymbols>
	<WasmEmitSymbolMap>true</WasmEmitSymbolMap>
	<WasmBuildNative>true</WasmBuildNative>
	
	<EmccExtraLDFlags>
		-s USE_SDL=2
		--embed-file Assets/
	</EmccExtraLDFlags>
</PropertyGroup>

<ItemGroup>
	<EmccExportedRuntimeMethod Include="SDL" />
	<EmccExportedRuntimeMethod Include="setMainLoop" />
</ItemGroup>

<Target Name="AddSDL" BeforeTargets="_GenerateManagedToNative" DependsOnTargets="_PrepareForWasmBuildNative">
	<ItemGroup>
		<_WasmPInvokeModules Include="SDL" />
	</ItemGroup>
</Target>

<Target Name="UnfreezeCache" DependsOnTargets="AddSDL" BeforeTargets="_WasmCompileNativeFiles;_WasmCompileAssemblyBitCodeFilesForAOT;_WasmCalculateInitialHeapSize;_WasmLinkDotNet;_CheckEmccIsExpectedVersion">
	<ItemGroup>
		<EmscriptenEnvVars Remove="EM_FROZEN_CACHE=True" />
		<EmscriptenEnvVars Include="EM_FROZEN_CACHE=0" />
		<EmscriptenEnvVars Include="FROZEN_CACHE=0" />
	</ItemGroup>
</Target>

However if I change my flags to use SDL2 + SDL2 Image like this

<EmccExtraLDFlags>
	-s USE_SDL=2
	-s USE_SDL_IMAGE=2
	-s SDL2_IMAGE_FORMATS='["png","jpg"]'
	--embed-file Assets/
</EmccExtraLDFlags>

I get this error that I just can’t seem to solve.

1>  File “C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.win-x64\8.0.19\tools\emscripten\emscripten.py”, line 831, in create_module1>    assert not metadata.invokeFuncs, “invoke_ functions exported but exceptions and longjmp are both disabled”1>AssertionError: invoke_ functions exported but exceptions and longjmp are both disabled

This originates from the emscripten.py file

  receiving += create_named_globals(metadata)
  module = []

  sending = create_sending(metadata, library_symbols)
  module.append('var wasmImports = %s;\n' % sending)
  if settings.ASYNCIFY and (settings.ASSERTIONS or settings.ASYNCIFY == 2):
    # instrumenting imports is used in asyncify in two ways: to add assertions
    # that check for proper import use, and for ASYNCIFY=2 we use them to set up
    # the Promise API on the import side.
    module.append('Asyncify.instrumentWasmImports(wasmImports);\n')

  if not settings.MINIMAL_RUNTIME:
    module.append("var asm = createWasm();\n")

  module.append(receiving)
  if settings.SUPPORT_LONGJMP == 'emscripten' or not settings.DISABLE_EXCEPTION_CATCHING:
    module.append(create_invoke_wrappers(metadata))
  else:
    assert not metadata.invokeFuncs, "invoke_ functions exported but exceptions and longjmp are both disabled"
  if settings.MEMORY64:
    module.append(create_wasm64_wrappers(metadata))
  return module

I’ve tried setting -s SUPPORT_LONGJMP=emscripten, -fno-exceptions, etc. However nothing seems to work. I don’t really have any experience with emscripten or wasm so I’m a bit lost on how to approach this problem, any help would be appreciated. Thank you