Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove empty export from transpiled ts file #1471

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/client/setup/code-runners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ export async function runJavaScript(code: string): Promise<CodeRunnerOutputs> {
return textRep
}

// The reflect-metadata runtime is available, so allow that to go through
function sanitizeJS(code: string) {
return code.replace(`import "reflect-metadata"`, '').replace(`require("reflect-metadata")`, '')
// The reflect-metadata runtime is available, so allow that to go through
code = code.replace(`import "reflect-metadata"`, '').replace(`require("reflect-metadata")`, '')
// Transpiled typescript sometimes contains an empty export, remove it.
code = code.replace('export {};', '')

return code
}

return allLogs
Expand Down