We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
js.Build
externals
Under assets, I have a JS file script.js with contents
assets
script.js
import '/external.js';
The file external.js has contents
external.js
console.log('This file should not be bundled!');
In my template, the script is included as follows:
{{- /* Make sure the resource "external.js" is published. */}} {{- (resources.Get "external.js").Publish }} {{- $script := resources.Get "script.js" }} {{- $opts := dict "format" "esm" "externals" (slice "/external.js") }} {{- $script = $script | js.Build $opts }} <script type="module" src="{{ $script.Permalink }}"></script>
The externals option seems to have no effect, and the file external.js is included in the bundled script.js. The bundled file looks as follows:
// ns-hugo-imp:/home/rnwst/src/hugo-test/assets/external.js console.log("This file should not be bundled!");
external.js should not be bundled, and the import statement in script.js should be left untouched.
hugo version
$ hugo version hugo v0.140.0+extended linux/amd64 BuildDate=unknown
The text was updated successfully, but these errors were encountered:
I created a reproducing example here: https://github.com/rnwst/hugo-testing/tree/hugo-github-issue-13183
Sorry, something went wrong.
I think I understand what's happening, and I suspect that this works fine for JS packages living in node_modules.
node_modules
js/esbuild: Don't try to resolve packages in /assets marked as external
a08a8b0
Fixes gohugoio#13183
0202539
Amazing, thank you for fixing this so quickly! Everything is working as expected on latest master.
Hugo is an awesome project, thank you very much for all your hard work!
bep
Successfully merging a pull request may close this issue.
Description and steps to reproduce
Under
assets
, I have a JS filescript.js
with contentsThe file
external.js
has contentsIn my template, the script is included as follows:
Actual behaviour
The
externals
option seems to have no effect, and the fileexternal.js
is included in the bundledscript.js
. The bundled file looks as follows:Expected behaviour
external.js
should not be bundled, and the import statement inscript.js
should be left untouched.What version of Hugo are you using (
hugo version
)?The text was updated successfully, but these errors were encountered: