Lambda Durable Functions SDK の DurableContext は named import できない
Durable Functions の公式ドキュメントの TypeScript サンプルに import { withDurableExecution, DurableContext } と書いてあったのでそのまま使ったら、Lambda 実行時に以下のエラーが出た。
SyntaxError: The requested module '@aws/durable-execution-sdk-js'
does not provide an export named 'DurableContext'DurableContext は TypeScript の型としてのみエクスポートされており、ランタイムの ESM モジュールには実体がない。.mjs ファイルで直接デプロイする場合は withDurableExecution のみ import する。
import { withDurableExecution } from "@aws/durable-execution-sdk-js";
export const handler = withDurableExecution(
async (event, context) => {
// context は自動的に DurableContext 型になる
await context.step("my-step", async () => { /* ... */ });
}
);TypeScript でビルドする場合は import type { DurableContext } を使えば型チェックが効く。ランタイムに .mjs を直接デプロイするケースでのみ問題になる。
