Iβm trying to use GetRemote to download/install 3rd party wasm and am getting a nil pointer return value assigned to my variable in the simple case. Within a with block, the context contains the temporary file that I can manipulate. It seems to me there is an issue with the simple case and error handling that I suspect is related to mediaType handling.
I duplicated the wasm mime type that exists in output format mediatypes (why are inputs and outputs not the same default list?) to hugos mediaTypes. This appears to have resolved the mimeType detection where the discussed solutions about passing a (dict "mediaType" "application/wasm") to GetRemote doesnβt seem to work.
Environment:
Alpine Linux 3.18
hugo v0.112.3+extended linux/amd64 BuildDate=unknown
Potentially related issues:
Potentially related documentation:
Server reports content type correctly: curl -v https://cdn.jsdelivr.net/gh/niutech/jxl.js/jxl_dec.wasm 2>&1 >/dev/null | grep ' content-type:'
< content-type: application/wasm
Local OS reports content type correctly: mimetype public/js/jxl_dec.wasm:
<head>
<!--
// Render local js to final js
{{
$jxl_loader := resources.Get "js/jxl.js"
| resources.Copy "js/jxl.js"
}}
// Render remote js to final js
{{
$jxl_decoder := resources.GetRemote .Site.Params.cdn.jxl.decoder
| resources.Copy "js/jxl_dec.js"
}}
// Throws an error that the returned object is null
// Render remote wasm to final wasm
{
$jxl_wasm := resources.Get .Site.Params.cdn.jxl.wasm
| resources.Copy "wasm/jxl_dec.wasm"
}}
// Error handling is required to get a non-null reference that can be published
{{ with resources.GetRemote .Site.Params.cdn.jxl.wasm | resources.Copy "js/jxl_dec.wasm" }}
{{ .Publish }}
{{ end }}
// Rendering the local tmp to the final copy works here
{{ $jxl_loader.Publish }}
{{ $jxl_decoder.Publish }}
// Trying to maintain the same semantics as javascript for wasm fails
{ $jxl_wasm.Publish }}
-->
</head>