Skip to content

Error: Top-level await is currently not supported with the "cjs" output format #908

@shawng

Description

@shawng

When I try to run something similar to the Eval via SDK tutorial:

npx braintrust eval tutorial.eval.ts

And in the eval task it runs code imported from another file with a top-level await, for example:

import { generateMarkdown } from '@/file-with-top-level-await-in-it';

Eval(...
    task: async (input) => await generateMarkdown(input),
)

I get the following error:

ERROR: Top-level await is currently not supported with the "cjs" output format

The package.json uses "type": "module" and tsconfig uses "module": "esnext" and "moduleResolution": "bundler" so it's unclear why it is trying to run in cjs mode instead of esm mode.

Any idea how to get this to run as esm with top-level await or otherwise fix the issue? Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions