Skip to content

chore(lib): Move cdktn package to src/ and lib/ layout - #145

Merged
jsteinich merged 3 commits into
open-constructs:mainfrom
X-Guardian:cdktn-src-change
May 19, 2026
Merged

jsteinich merged 3 commits into
open-constructs:mainfrom
X-Guardian:cdktn-src-change

Conversation

@X-Guardian

@X-Guardian X-Guardian commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Summary

Migrates the cdktn package to the standard src/ (sources) + lib/ (build output) layout used by every other workspace package. Sources and compile output were previously co-located in lib/, which caused stale .js/.d.ts artifacts to confuse knip after every local yarn build (false-positive "unused dependency" reports for json-stable-stringify, yazl, @types/json-stable-stringify, @types/semver because TS module resolution was preferring the stale .d.ts typings over the actual .ts sources).

Why

  • After #116 migrated other packages to src/ → build/, cdktn was the only holdout still emitting compiled output next to sources.
  • Mixed layout meant knip would silently fail locally after a build, even though it was clean in CI (CI runs knip on a fresh checkout with no compiled artifacts).

What changed

Source layout:

  • 85 .ts source files moved: packages/cdktn/lib/**/*.ts → packages/cdktn/src/**/*.ts (subdir layout preserved: backends/, functions/, hcl/, private/, synthesize/, testing/, tokens/, validations/)
  • package.json "main" and "types" continue to point at lib/index.js / lib/index.d.ts — distribution surface is unchanged.

Build configuration (packages/cdktn/package.json):

  • Added "jsii"."tsc": { "outDir": "lib", "rootDir": "src" } — JSII regenerates tsconfig.json to compile from src/ and emit to lib/.
  • Added "jsii"."excludeTypescript": ["src/**/__tests__/**"] — three colocated __tests__ files inside src/testing/ import from test/helper/ (outside rootDir); excluding them keeps JSII's rootDir constraint satisfied. Jest still picks them up via testMatch.

Test wiring:

  • 33 test files + 5 helpers updated: from "../lib" → from "../src" (and ../../lib → ../../src for nested test/helper/ and test/tokens/ files).
  • Added packages/cdktn/tsconfig.test.json — extends the JSII-generated tsconfig.json but widens rootDir to . and excludes lib/**/*.d.ts. Required because (a) test files live outside rootDir: src and ts-jest can't compute output paths for out-of-tree files, and (b) without excluding lib/, ts-jest sees both src/terraform-count.ts and lib/terraform-count.d.ts as separate type declarations and rejects assignment between them.
  • Updated jest.config.js to point ts-jest at tsconfig.test.json.

Knip + docs:

Checklist

  • I have updated the PR title to match CDKTN's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

@X-Guardian X-Guardian mentioned this pull request May 14, 2026
2 of 8 tasks
@X-Guardian
X-Guardian marked this pull request as ready for review May 19, 2026 08:25
@X-Guardian
X-Guardian requested a review from a team as a code owner May 19, 2026 08:25
@jsteinich
jsteinich merged commit c86b27a into open-constructs:main May 19, 2026
271 checks passed
jsteinich added a commit that referenced this pull request May 26, 2026
## 0.23.2

### chore
- chore: Update npm version to support OIDC trusted publishing
[\#205](#205)
- chore: Fix publib running to use npx rather than yarn
[\#203](#203)
- chore(tests): Add test for Node type stripping
[\#198](#198)
- chore(gha): Enable NPM OIDC Publishing
[\#195](#195)
- chore: remove mention of Hashicorp support
[\#193](#193)
- chore: consolidate release workflows for npm OIDC
[\#192](#192)
- chore: tell users to search for cdktn on npm
[\#185](#185)
- chore: replace cdk.tf/modules-and-providers links
[\#184](#184)
- chore: fix references to cdktf in TS examples
[\#183](#183)
- chore: point to correct docs repo
[\#181](#181)
- chore: delete Vercel config for cdk.tf site
[\#180](#180)
- chore(gha): optimise integration & provider-integration CI pipelines
[\#178](#178)
- chore(gha): optimise examples CI pipeline
[\#175](#175)
- chore: migrate jest to @nx/jest plugin with swc-jest
[\#160](#160)
- chore: replace yazl with fflate
[\#148](#148)
- chore(lib): Move cdktn package to src/ and lib/ layout
[\#145](#145)
- chore: Consolidate PR CI into tiered orchestrator workflow
[\#143](#143)

### fix

- fix(gha): Need to grant permission on workflow call job
[\#196](#196)
- fix(cli): Fix input getting split between cdktn and Terraform
[\#191](#191)
- fix(cli): restore non-bundled dependencies
[\#190](#190)
- fix: Configurable dist artifact name to fix release workflows
[\#189](#189)
- fix(tests): pass --no-compile to pip in python integration tests
[\#188](#188)
- fix(cli): pass languageOptions to `get`
[\#179](#179)
- fix(provider-generator): add missing semicolons
[\#177](#177)

### feat

- feat(provider-generator): configurable import extensions
[\#151](#151)
@github-actions

Copy link
Copy Markdown
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants