Js.build getting error

My current Hugo version is 0.124.0. I’m trying to use js.Build in my project but encountering an error. Attached is the code and screenshot for reference.


   {{ $js := resources.Get "/js/index.js" | js.Build (dict "params" (dict "api" "https://example.org/api")) }}


import params from '@params';


I am unable to reproduce the problem as described using v0.124.0 or v0.124.1.

git clone --single-branch -b hugo-forum-topic-49255 https://github.com/jmooring/hugo-testing hugo-forum-topic-49255
cd hugo-forum-topic-49255
hugo server

The JS bundling takes place in layouts/_default/baseof.html, lines 8-10.

{{ with resources.Get "/js/index.js" | js.Build (dict "params" (dict "api" "https://example.org/api")) }}
  <script type="module" src="{{ .RelPermalink }}"></script>
{{ end }}

The bundled JS looks like this…


…which looks nothing like your screen capture.

1 Like

This error only occurs when I try to import ‘@params

The vars are already injected.

Do you have any idea where I made a mistake? I’ve been trying this for a week.

I’ve shared a working example with you.

I have no idea what you are doing unless you do the same.

Thanks @jmooring