From c2ce1c296349be76893b495638a37ff6fb8fce55 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 19:00:16 +0000 Subject: [PATCH 1/2] Initial plan From 3cccc02ed652033e899696cd1b7c28a900555fa4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 19:11:41 +0000 Subject: [PATCH 2/2] Fix templateExportDefault: true not adding export default to bare module-level templates Co-authored-by: gitKrystan <14152574+gitKrystan@users.noreply.github.com> --- src/printers.ts | 5 +++++ .../__snapshots__/template-export-default.test.ts.snap | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/printers.ts b/src/printers.ts index 78f75c3c..a81e446b 100644 --- a/src/printers.ts +++ b/src/printers.ts @@ -40,6 +40,11 @@ function embed(path: AstPath, options: PluginOptions) { ); const printed = printTemplateTag(content); + + if (options.templateExportDefault && path.parent?.type === 'Program') { + printed.unshift('export ', 'default '); + } + saveCurrentPrintOnSiblingNode(path, printed); return printed; } catch (error) { diff --git a/tests/unit-tests/config/__snapshots__/template-export-default.test.ts.snap b/tests/unit-tests/config/__snapshots__/template-export-default.test.ts.snap index c10016e6..2393ac58 100644 --- a/tests/unit-tests/config/__snapshots__/template-export-default.test.ts.snap +++ b/tests/unit-tests/config/__snapshots__/template-export-default.test.ts.snap @@ -170,7 +170,7 @@ exports[`config > templateExportDefault: true > it formats ../cases/gjs/one-line exports[`config > templateExportDefault: true > it formats ../cases/gjs/preceded-by-object.gjs 1`] = ` "const foo = {}; - +export default " `; @@ -276,12 +276,12 @@ export default Route( `; exports[`config > templateExportDefault: true > it formats ../cases/gjs/simple.gjs 1`] = ` -" +"export default " `; exports[`config > templateExportDefault: true > it formats ../cases/gjs/simple-with-tag.gjs 1`] = ` -"