hi. I’m trying to do some hello world level stuff and I can’t figure it out, please help.
// assets/js/tada.js
export function tada() {
alert("TADA!!");
}
this one works, as I’m not calling js.Build
//layouts/shortcodes/tada_ok.html
{{ $js := resources.Get "/js/tada.js" }}
<script src="{{ $js.RelPermalink }}"> </script>
<button onclick="tada()">pressme</button>
but if I add the js.Build step …
//layouts/shortcodes/tada_notok.html
{{ $js := resources.Get "/js/tada.js" | js.Build }}
<script src="{{ $js.RelPermalink }}"> </script>
<button onclick="tada()">pressme</button>
… clicking on the button gives me the “tada is not defined” error.
I can see that the compilation did something to my code:
// built /js/tada.js
(() => {
// <stdin>
function tada() {
alert("tada");
}
})();
What’s happening ?