Top-level await not available in build environment for Sanity config file
Last updated: Jun 6, 2023
I’m using a top-level await to get the current user in my sanity.config.ts and it works fined in dev but throws “Top-level await is not available in the configured target environment ” when
npm run build
. I don’t know if there is a way to configure the targets that are used by esbuild. The top level await was actually recommended by a sanity member so it doesn’t seem like I’m doing something non-canon here.