Open arjunyel opened 1 month ago
The es2023 esbuild setting should be compiling the await using, the error implies the target is still ESNext
await using
| Error | Unexpected identifier 'dbHandle' | ↳ at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:168:18) | ↳ at callTranslator (node:internal/modules/esm/loader:279:14) | ↳ at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:30) | ↳ at async link (node:internal/modules/esm/module_job:78:21)
/// <reference path="./.sst/platform/config.d.ts" /> export default $config({ app(input) { return { name: "test", removal: input?.stage === "production" ? "retain" : "remove", home: "aws", }; }, async run() { const test = new sst.aws.Function("Test", { url: true, handler: "./src/lambda.handler", runtime: "nodejs20.x", architecture: "arm64", nodejs: { esbuild: { target: "es2023", supported: { using: false }, }, }, }); return { test: test.url, }; }, });
import postgres from "postgres"; import { drizzle } from "drizzle-orm/postgres-js"; Symbol.dispose ??= Symbol("Symbol.dispose"); Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose"); const getDbHandle = () => { const pgClient = postgres("Resource.PostgresUrl.value"); return { db: drizzle(pgClient), async [Symbol.asyncDispose]() { await pgClient.end(); }, }; }; export async function handler() { await using dbHandle = getDbHandle(); return { statusCode: 200, body: "Hello World", }; }
The es2023 esbuild setting should be compiling the
await using
, the error implies the target is still ESNext