mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(producer): indirect lambda-local import path so tsc can't resolve it
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.
This commit is contained in:
@@ -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<RunLambdaLocalRender> {
|
||||
const mod = (await import("./regression-harness-lambda-local.js")) as {
|
||||
const mod = (await import(LAMBDA_LOCAL_MODULE)) as {
|
||||
runLambdaLocalRender: RunLambdaLocalRender;
|
||||
};
|
||||
return mod.runLambdaLocalRender;
|
||||
|
||||
Reference in New Issue
Block a user