aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/resource_transformers/js/js_integration_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-12-22 20:46:19 +0100
committerBjørn Erik Pedersen <[email protected]>2024-12-22 21:29:18 +0100
commit020253904f335643ead1c390f9fa52f24b185a3d (patch)
treec89e970e366a2e5191655d8a4919c1461d07d4c2 /resources/resource_transformers/js/js_integration_test.go
parent4a5e94087ba2fe1405ad2edbcbeeccac2a6147a6 (diff)
downloadhugo-020253904f335643ead1c390f9fa52f24b185a3d.tar.gz
hugo-020253904f335643ead1c390f9fa52f24b185a3d.zip
js/esbuild: Don't try to resolve packages in /assets marked as external
Fixes #13183
Diffstat (limited to 'resources/resource_transformers/js/js_integration_test.go')
-rw-r--r--resources/resource_transformers/js/js_integration_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/resources/resource_transformers/js/js_integration_test.go b/resources/resource_transformers/js/js_integration_test.go
index c62312ef5..9cee19a86 100644
--- a/resources/resource_transformers/js/js_integration_test.go
+++ b/resources/resource_transformers/js/js_integration_test.go
@@ -391,3 +391,32 @@ class A {}
}).Build()
b.AssertFileContent("public/js/main.js", "__decorateClass")
}
+
+// Issue 13183.
+func TestExternalsInAssets(t *testing.T) {
+ files := `
+-- assets/js/util1.js --
+export function hello1() {
+ return 'abcd';
+}
+-- assets/js/util2.js --
+export function hello2() {
+ return 'efgh';
+}
+-- assets/js/main.js --
+import { hello1 } from './util1.js';
+import { hello2 } from './util2.js';
+
+hello1();
+hello2();
+-- layouts/index.html --
+Home.
+{{ $js := resources.Get "js/main.js" | js.Build (dict "externals" (slice "./util1.js")) }}
+{{ $js.Publish }}
+`
+
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
+
+ b.AssertFileContent("public/js/main.js", "efgh")
+ b.AssertFileContent("public/js/main.js", "! abcd")
+}