Skip to content

chore: Migrate package manager from yarn to pnpm#170

Draft
X-Guardian wants to merge 44 commits into
open-constructs:mainfrom
X-Guardian:chore/pnpm
Draft

chore: Migrate package manager from yarn to pnpm#170
X-Guardian wants to merge 44 commits into
open-constructs:mainfrom
X-Guardian:chore/pnpm

Conversation

@X-Guardian
Copy link
Copy Markdown
Contributor

Description

Test for pnpm migration

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 force-pushed the chore/pnpm branch 5 times, most recently from bd7db52 to 2d3ec54 Compare May 12, 2026 11:57
@X-Guardian X-Guardian force-pushed the chore/pnpm branch 4 times, most recently from 550e7a7 to 7ef1d6f Compare May 22, 2026 16:29
@X-Guardian X-Guardian force-pushed the chore/pnpm branch 3 times, most recently from 04e931c to b60c70e Compare May 24, 2026 14:08
gabegorelick added a commit to gabegorelick/cdk-terrain that referenced this pull request May 25, 2026
gabegorelick added a commit to gabegorelick/cdk-terrain that referenced this pull request May 25, 2026
so0k pushed a commit to gabegorelick/cdk-terrain that referenced this pull request May 25, 2026
gabegorelick added a commit to gabegorelick/cdk-terrain that referenced this pull request May 26, 2026
jsteinich pushed a commit that referenced this pull request May 27, 2026
### Description

Updated the example `help` files to match the current `cdktn init`
templates. This removes some of the diff from #170 (yarn references)

Also:
- Updated the nuget link to
https://www.nuget.org/packages?q=Io.Cdktn.Providers and on the template
- Updated the Maven link to https://mvnrepository.com/artifact/io.cdktn
and on the template
- Added missing EOF line feeds where applicable on the template help
files

### Checklist

- [x] I have updated the PR title to match [CDKTN's style
guide](https://github.com/open-constructs/cdk-terrain/blob/main/CONTRIBUTING.md#pull-requests-1)
- [ ] 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](https://github.com/open-constructs/cdk-terrain-docs/tree/main/content)
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

<!-- If this is still a work in progress, feel free to open a draft PR
until you're able to check off all the items on the list above -->

---------

Co-authored-by: Simon Heather <simon.heather@yulife.com>
gabegorelick added a commit to gabegorelick/cdk-terrain that referenced this pull request Jun 1, 2026
jsteinich pushed a commit that referenced this pull request Jun 4, 2026
### Description

Aligns every workspace package and example on TypeScript 5.9.3, and
fixes the two `WebAssembly.instantiate` call sites (`@cdktn/hcl-tools`
and `@cdktn/hcl2json`) that fail to compile under newer TS.

#### Why 

The version was drifting. `@cdktn/hcl-tools` declared `^5.7.3` while the
other 10 workspace packages were exact-pinned to `5.4.5`, and the 22
example projects were split between `5.4.5` and `^5.7.3`. Under yarn
workspaces (hoisted node_modules) this drift was invisible — every
package got whatever yarn happened to hoist at the root. Under the
upcoming pnpm migration (strict, isolated `node_modules/.pnpm/` layout)
each package resolves its own range, so `hcl-tools` lands on TS 5.9.3
while everything else lands on 5.4.5 — and the build of `hcl-tools`
fails because TS 5.9.3 resolves `WebAssembly.instantiate(buffer, …)`
differently. We hit this when reproducing the pnpm branch (see "Root
cause" below).

The structural problem is the drift itself — over thirty independent
pins inviting future divergence. Two changes fix it together:

| Change | Effect |
|---|---|
| Every workspace package and example: `"typescript": "^5.0.0"` | Each
manifest declares only its real constraint ("we compile under TS 5.x").
|
| Root `resolutions`: `"**/typescript": "5.9.3"` | Single source of
truth for the actual resolved version. Bump = one line. |

The root devDep keeps `typescript` because root-level tooling
(`tsc-files`, `typescript-eslint`, `@typescript-eslint/parser`) declares
it as a peer.

**Root cause of the `bridge.ts` failures:**

In TS 5.7+ `Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>`
and `ArrayBufferView<TArrayBuffer extends ArrayBufferLike =
ArrayBufferLike>` became generic. In TS 5.9.3 the overload resolver no
longer treats `Buffer<ArrayBufferLike>` as assignable to DOM's
`BufferSource = ArrayBufferView | ArrayBuffer`, so
`WebAssembly.instantiate(buffer, importObject)` falls through from

function instantiate(bytes: BufferSource, …):
Promise<WebAssemblyInstantiatedSource>

to the second overload

    function instantiate(moduleObject: Module, …): Promise<Instance>

`WebAssemblyInstantiatedSource` has a `.instance` property; `Instance`
does not. So `result.instance` errors with `TS2339`. The same code is
fine under TS 5.4.5/5.8.x because those versions matched the first
overload. Both `packages/@cdktn/hcl-tools/src/bridge.ts` and
`packages/@cdktn/hcl2json/src/bridge.ts` use the same pattern and need
the same fix.

This is a prerequisite for #170 

**Approach:** four steps.

1. **Loosen per-package ranges to `^5.0.0`** in all eleven workspaces
(`cdktn`, `cdktn-cli`, `@cdktn/cli-core`, `@cdktn/commons`,
`@cdktn/hcl-tools`, `@cdktn/hcl2cdk`, `@cdktn/hcl2json`,
`@cdktn/provider-generator`, `@cdktn/provider-schema`,
`tools/generate-function-bindings`, root) and across the 22
`examples/typescript/**` projects. Honest declarations: each package is
built and tested under whatever TS 5.x the root resolves.
2. **Pin via root `resolutions`**: add `"**/typescript": "5.9.3"`
alongside the existing `**/@types/react` and `**/jsii` resolutions.
Future bumps touch one line.
3. **Fix both `bridge.ts` call sites** — wrap the Buffer in `new
Uint8Array(...)` before passing it to `WebAssembly.instantiate` in
`packages/@cdktn/hcl-tools/src/bridge.ts` and
`packages/@cdktn/hcl2json/src/bridge.ts`. This pins the overload to the
`BufferSource` form regardless of how TS resolves
`Buffer<ArrayBufferLike>` against `BufferSource` in any future TS
release.
4. **`yarn install`** — refreshes lockfile; every requested `typescript`
range now resolves to 5.9.3.

The `bridge.ts` changes are required for this bump — without them
`@cdktn/hcl-tools` and `@cdktn/hcl2json` do not compile under TS 5.9.3.

**One incidental fix** — `examples/typescript/aws-multiple-stacks`
declared `@types/node: 18.11.19` while every other example declared
`20.17.51`. TS 5.9.3 surfaces the staleness as a structural-typing error
("Interface 'Buffer' incorrectly extends interface
'Uint8Array<ArrayBufferLike>'"). Bumped to `20.17.51` to match the rest.

### Checklist

- [x] I have updated the PR title to match [CDKTN's style
guide](https://github.com/open-constructs/cdk-terrain/blob/main/CONTRIBUTING.md#pull-requests-1)
- [ ] 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](https://github.com/open-constructs/cdk-terrain-docs/tree/main/content)
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

---------

Co-authored-by: Simon Heather <simon.heather@yulife.com>
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.

1 participant