From 7545e08c4012cb144b744ee976ea611f98b710dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 18 Oct 2024 17:59:04 +0200 Subject: [PATCH] Export --- tpl/js/batch-esm-callback.gotmpl | 3 +-- tpl/js/batch.go | 7 ++++--- tpl/js/batch_integration_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tpl/js/batch-esm-callback.gotmpl b/tpl/js/batch-esm-callback.gotmpl index e0799ee433d..90d662171de 100644 --- a/tpl/js/batch-esm-callback.gotmpl +++ b/tpl/js/batch-esm-callback.gotmpl @@ -1,6 +1,5 @@ {{ range $i, $e := .Modules -}} - import { {{ printf "% as Mod%d" .CallbackExport $i }} } from - "{{ .ImportPath }}"; + {{ printf "import { %s as Mod%d } from %q;" .CallbackExport $i .ImportPath }} {{ end -}} {{ range $i, $e := .Callbacks }} {{ $id := printf "Callback%d" $i }} diff --git a/tpl/js/batch.go b/tpl/js/batch.go index b2d4bac43b4..d92db9a67ff 100644 --- a/tpl/js/batch.go +++ b/tpl/js/batch.go @@ -804,9 +804,10 @@ func (b *batcher) doBuild() (*Package, error) { }) bt := batchTemplateExecutionsContext{ - ID: vv.ID, - r: vv.Resource, - ImportPath: impPath, + ID: vv.ID, + r: vv.Resource, + CallbackExport: vv.CallbackExport, + ImportPath: impPath, } state.importResource.Set(bt.ImportPath, vv.Resource) for _, vvv := range instances.ByScriptID(vv.ID) { diff --git a/tpl/js/batch_integration_test.go b/tpl/js/batch_integration_test.go index 940025b1148..fcb8627f9f6 100644 --- a/tpl/js/batch_integration_test.go +++ b/tpl/js/batch_integration_test.go @@ -264,7 +264,7 @@ Home. {{ with .Script "r2" }} {{ .SetOptions (dict "resource" (resources.Get "js/react2.jsx") - "exporrt" "MyOtherButton" + "callbackExport" "MyOtherButton" "importContext" $otherCSS "params" (dict "id" "r2") )