From 187dfd5b6cb3a1cbfba17262d66f8ab0c1ef7f76 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 17 May 2026 23:11:45 +0000 Subject: [PATCH] fix(producer): indirect lambda-local import path so tsc can't resolve it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tsconfig `exclude` list isn't enough to keep producer's tsc emit pass from pulling `regression-harness-lambda-local.ts` (and its `@hyperframes/aws-lambda` static imports) into the program — tsc still statically resolves the path in `await import("./regression-harness-lambda-local.js")` from `regression-harness.ts`, walks into the excluded file, and fails on the missing aws-lambda type declarations. Reproduction (clean workspace, no aws-lambda dist yet, mirrors CI): rm -rf packages/{aws-lambda,producer,core}/dist bun run build # @hyperframes/producer build: src/regression-harness-lambda-local.ts(36,70): # error TS2307: Cannot find module '@hyperframes/aws-lambda' or its # corresponding type declarations. Fix: route the dynamic import path through a top-level string constant so tsc can't statically resolve the target. tsc keeps the type-only imports (`RunLambdaLocalRender` from the no-aws-lambda types file) and treats the dynamic-import target as opaque. `tsx` resolves the path normally at runtime, so `--mode=lambda-local` is unchanged. --- packages/producer/src/regression-harness.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/producer/src/regression-harness.ts b/packages/producer/src/regression-harness.ts index 9d413a79d..015cae007 100644 --- a/packages/producer/src/regression-harness.ts +++ b/packages/producer/src/regression-harness.ts @@ -44,10 +44,18 @@ import { // `@hyperframes/aws-lambda`, whose types come from `dist/index.d.ts` after // aws-lambda's build runs — a chicken-and-egg with producer's tsc that // would otherwise fail the whole-repo build. +// +// The dynamic import path is indirected through a variable so tsc can't +// statically resolve the target file. Without this indirection tsc still +// pulls `regression-harness-lambda-local.ts` (and its `@hyperframes/aws-lambda` +// imports) into the program even though the tsconfig `exclude` list +// nominally hides it. `tsx` resolves the path normally at runtime. import type { RunLambdaLocalRender } from "./regression-harness-lambda-local-types.js"; +const LAMBDA_LOCAL_MODULE = "./regression-harness-lambda-local.js"; + async function loadLambdaLocalRender(): Promise { - const mod = (await import("./regression-harness-lambda-local.js")) as { + const mod = (await import(LAMBDA_LOCAL_MODULE)) as { runLambdaLocalRender: RunLambdaLocalRender; }; return mod.runLambdaLocalRender;