Skip to content

Commit

Permalink
fix(generators): Fix JavaScript generators
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Jul 10, 2024
1 parent 49b9f70 commit 3d6b7de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/generators/src/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
5 changes: 5 additions & 0 deletions packages/generators/test/commons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@ import something from './file.js';
const otherThing = "Hello";
`
)

strictEqual(
getJavaScript(`import { authentication } from './authentication'`),
`import { authentication } from './authentication.js'`
)
})
})

0 comments on commit 3d6b7de

Please sign in to comment.