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") )