Repository navigation
[2.x] Use the published v1 node types in @codama/upgrade - #1201
Conversation
|
44a2217 to
5ce0092
Compare
74545e7 to
cd53890
Compare
trevor-cortex
left a comment
There was a problem hiding this comment.
Summary
Replaces the ~90-file hand-maintained v1 node-types snapshot under packages/upgrade/src/v1/ with the published @codama/node-types@1.11.0, installed under an exactly pinned @codama/node-types-v1 npm alias. src/v1/index.ts becomes a one-line export type * from '@codama/node-types-v1', a paths mapping in packages/upgrade/tsconfig.json works around TypeScript's name@version package dedup while the workspace @codama/node-types is still at 1.11.0, and CONTRIBUTING.md / the package README / the v2/index.ts docblock are updated to describe the pin-instead-of-copy workflow.
This is a clear improvement — it removes a large surface of copied source, makes "the v1 types" unambiguously the thing that was actually published, and the port-forward-by-patch mechanism the snapshot existed for is no longer needed.
What I verified
tsconfig.declarations.jsonextends./tsconfig.json, so thepathsmapping applies to bothtsc --noEmitand the declaration build.pathsdoesn't rewrite emitted specifiers, sodist/types/v1/index.d.tswill still say@codama/node-types-v1, which consumers resolve through the publisheddependenciesentry. Correct that this lives independenciesrather thandevDependencies— consumers' type-checkers need it installed.- Root
tsconfig.jsonsets nobaseUrl, so the./node_modules/...path is resolved relative topackages/upgrade/, anddist/types/index.d.tsmatches thetypesentry of@codama/node-typeson1.x. - Spot-checked the
1.xbranch:codamaVersion.tsis byte-identical to the deleted snapshot, andsrc/index.tsthere exportsbrands/Docs/Version/generatedplus the deprecatedProgramVersion, consistent with the PR's "identical exceptProgramVersion" claim. - Consumer-side dedup is benign: a consumer still on
@codama/node-types@1.11.0(the exact audience of this package) would have TS dedupe the alias against their own copy, which is the same content;@codama/upgrade's own@codama/node-types@2.xdependency has a different version and won't collide. - No
packages/upgrade/CHANGELOG.mdexists, so the package hasn't shipped yet and this doesn't need its own changeset beyond whatever already covers the first release.
Things to watch
- Dependabot will try to move the pin.
.github/dependabot.ymlruns daily npm updates with no ignore list, and Dependabot understandsnpm:aliases, so it will open PRs bumping@codama/node-types-v1to 2.x (CI typecheck would reject those, but they're noise) and would happily land a future1.11.1docs-only patch, which contradicts the "moving the pin is a deliberate change" invariant inCONTRIBUTING.md. Suggest adding anignoreentry for it — see inline. - The
pathsworkaround becomes a no-op as soon as the workspace@codama/node-typesis versioned2.0.0-rc.n(the "same-major invariant" release step). It's harmless to leave in place, but a one-line note in the comment about when it can be dropped would help the next person who wonders why it's there — see inline.
Notes for subsequent reviewers
- The PR file list is truncated at 100 in the GitHub UI; the substantive changes not in that first page are
packages/upgrade/src/v1/index.ts,packages/upgrade/src/v2/index.ts,packages/upgrade/tsconfig.json, andpnpm-lock.yaml. Worth opening those explicitly rather than assuming the diff is deletions-only. - Nothing to check at runtime:
export type *is erased by both tsup/esbuild and vitest, so bundle output and the agadoo tree-shake test are unaffected.
5ce0092 to
da6ac69
Compare
cd53890 to
f1c5fa8
Compare
da6ac69 to
c4ebdc4
Compare
c4ebdc4 to
9814a53
Compare

This PR replaces the hand-maintained copy of the v1 node types in
@codama/upgradewith the published types of the last v1 release, installed under an exactly pinned alias:src/v1/index.tsnow re-exports that alias, and the ~90 copied files undersrc/v1/are deleted. The published 1.11.0 types are structurally identical to the copy they replace; the only addition is the deprecatedProgramVersionalias. Since the alias is type-only, it adds nothing to the runtime bundle.While the workspace
@codama/node-typesis still versioned 1.11.0, TypeScript treats it and the alias as the same package and resolves both to the workspace v2 types. Apathsmapping inpackages/upgrade/tsconfig.jsonpoints the alias at its own files to work around this.CONTRIBUTING.mdand the package README are updated to describe pinning old node types instead of copying them.