From 3d6b7de2299dad5f3eb470e722f6ed3c8721274b Mon Sep 17 00:00:00 2001 From: daffl Date: Tue, 9 Jul 2024 17:15:16 -0700 Subject: [PATCH] fix(generators): Fix JavaScript generators --- packages/generators/src/commons.ts | 5 +++++ packages/generators/test/commons.test.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/packages/generators/src/commons.ts b/packages/generators/src/commons.ts index 9a284f36fb..ce5cadfafe 100644 --- a/packages/generators/src/commons.ts +++ b/packages/generators/src/commons.ts @@ -180,6 +180,11 @@ export const getJavaScript = (typescript: string, options: ts.TranspileOptions = ...options.compilerOptions } }) + const { outputText } = transpiled + + if (outputText.startsWith('export {}') && typescript.startsWith('import')) { + return fixLocalImports(typescript) + } return fixLocalImports(restoreNewLines(transpiled.outputText)) } diff --git a/packages/generators/test/commons.test.ts b/packages/generators/test/commons.test.ts index f008ff03f8..86a74df146 100644 --- a/packages/generators/test/commons.test.ts +++ b/packages/generators/test/commons.test.ts @@ -31,5 +31,10 @@ import something from './file.js'; const otherThing = "Hello"; ` ) + + strictEqual( + getJavaScript(`import { authentication } from './authentication'`), + `import { authentication } from './authentication.js'` + ) }) })