Skip to content

fix: publish declarations from @aligent/cdk-secure-rest-api#1689

Merged
toddhainsworth merged 1 commit into
mainfrom
fix/secure-rest-api-missing-declarations
May 18, 2026
Merged

fix: publish declarations from @aligent/cdk-secure-rest-api#1689
toddhainsworth merged 1 commit into
mainfrom
fix/secure-rest-api-missing-declarations

Conversation

@toddhainsworth
Copy link
Copy Markdown
Member

Summary

  • @aligent/cdk-secure-rest-api@1.1.0 shipped without .d.ts files because the package had no .npmignore, so npm pack fell back to the workspace .gitignore (which excludes build outputs).
  • Consumers with isolatedModules: true resolved index.ts directly and hit TS1205 on the type re-exports.
  • TS-aware loaders like tsx additionally preferred the shipped .ts source over index.js, causing SecureRestApi is not a constructor at runtime in ESM consumers.

Changes

  • Add packages/constructs/secure-rest-api/.npmignore matching sibling packages — excludes *.ts source / tests / configs while preserving *.d.ts declarations.
  • Split index.ts into a value re-export (SecureRestApi) and export type re-export (SecureRestApiProps, SecureRestApiRoute) — defends against any future scenario where consumers resolve the source again.
  • Add a patch changeset.

Verified locally with npm pack --dry-run: tarball is now 7 files (down from 13), no .ts source, includes both index.d.ts and lib/secure-rest-api.d.ts.

Test plan

  • yarn nx lint secure-rest-api passes
  • yarn nx build secure-rest-api produces index.d.ts + lib/secure-rest-api.d.ts
  • yarn nx test secure-rest-api passes (12/12)
  • npm pack --dry-run lists *.d.ts and excludes *.ts source, test, and config files
  • After publish to 1.1.1, consumer-side .yarn/patch for this package can be removed

Follow-ups (not in this PR)

  • prerender-fargate is missing .npmignore for the same reason — likely has the same bug in its published tarball.
  • Type re-export hygiene (export type) is missing across most packages — currently masked by .d.ts shipping correctly, but worth a sweep.
  • Consider a CI guard (npm pack --dry-run | grep -q '\.d\.ts') to catch this class of regression before publish.

The package shipped without `.d.ts` files because it had no `.npmignore`,
so `npm pack` fell back to the workspace `.gitignore` (which excludes
build outputs). Consumers with `isolatedModules: true` resolved
`index.ts` directly and hit TS1205 on the type re-exports.

Add a package `.npmignore` matching sibling packages and split
`index.ts` into a value re-export and an `export type` re-export.
@toddhainsworth toddhainsworth marked this pull request as ready for review May 18, 2026 06:00
@toddhainsworth toddhainsworth requested a review from a team as a code owner May 18, 2026 06:00
@toddhainsworth toddhainsworth merged commit c879c3a into main May 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants