Repository navigation
fix(codegen): publish built JavaScript with its runtime dependencies (#94) - #97
Conversation
…94) The published package pointed `exports` at raw TypeScript and listed its runtime imports only in devDependencies. A consumer could not import it after `npm install`. - Build ESM JavaScript and `.d.ts` files to `dist/` with `tsc`. - Point `main`, `module`, `types` and `exports` at `dist/`. Ship only `dist/`, the runtime template, the README and the LICENSE. - Move `json-schema-to-zod`, `prettier` and `openapi-types` to `dependencies`. - Add a CI step that packs the package, installs the tarball in an empty project and runs `codegen` with plain Node. Closes #94
🦋 Changeset detectedLatest commit: ec96f7f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
🟢 Approval recommended
The packaging changes consistently address the installation failure, with consumer smoke coverage and no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes #94 by making @taskade/mcp-openapi-codegen usable after npm installation without a TypeScript loader.
Changes:
- Publishes built ESM JavaScript, declarations, and required runtime dependencies.
- Updates module paths and preserves the runtime template.
- Adds an isolated tarball smoke test and patch release metadata.
| File | Description |
|---|---|
packages/openapi-codegen/tsconfig.build.json |
Configures JavaScript and declaration output. |
packages/openapi-codegen/src/parser.ts |
Uses an ESM-compatible import extension. |
packages/openapi-codegen/src/index.ts |
Uses an ESM-compatible export extension. |
packages/openapi-codegen/src/codegen.ts |
Updates imports and runtime template lookup. |
packages/openapi-codegen/package.json |
Defines built entry points, dependencies, and packaging hooks. |
packages/openapi-codegen/LICENSE |
Includes the MIT license in the package. |
.github/workflows/ci.yml |
Tests the installed tarball outside the workspace. |
.changeset/codegen-ship-dist.md |
Records the packaging fix for a patch release. |
Review effort: Balanced
`import.meta.dirname` needs Node 20.11, so the package needed an
`engines` floor. Yarn v1 enforces `engines` on workspace packages, and
that floor stopped `yarn install` on Node 20.0 to 20.10. CONTRIBUTING
allows Node 20.0.
`new URL('../src/runtime.ts', import.meta.url)` works on every Node
version with ESM. The package thus needs no `engines` field.
Code reviewNo issues found at the current head. Checked for bugs, for the history of the changed files, for review comments on earlier PRs that touched them, and for code-comment guidance. One finding was fixed before this comment, in ec96f7f: the first commit added mcp/packages/openapi-codegen/src/codegen.ts Lines 74 to 81 in ec96f7f |
|
@deanzaka for review. This PR fixes the npm package Impact
Developer flowBefore (0.0.6): After (next patch release): Repo build (unchanged result): QA
|
Summary
@taskade/mcp-openapi-codegen0.0.6 on npm cannot be imported afternpm install. Itsexportsfield points at raw TypeScript (./src/index.ts), and its runtime imports are only indevDependencies. This PR publishes built ESM JavaScript and.d.tsfiles fromdist/and lists the runtime imports independencies.Failures on 0.0.6 (verified with the tarball from the public registry, Node 22):
Changes
packages/openapi-codegen/tsconfig.build.json: new.tscemits ESM JavaScript and.d.tsfiles todist/. The tests and the runtime template are not compiled.packages/openapi-codegen/package.json:main,module,typesandexports["."]point atdist/.exportsalso maps./package.json.filesships onlydist/andsrc/runtime.ts. npm adds the README and the LICENSE. The tests andtsconfig.jsonno longer ship.json-schema-to-zod,prettierandopenapi-typesmove todependencies, with the ranges from the lockfile.openapi-typesis a type-only import, but the public.d.tsrefers to it.@readme/openapi-parserand@modelcontextprotocol/sdkstay indevDependencies. The package does not import them at run time. The server generator scripts use@readme/openapi-parser, and the README tells users to install it.@modelcontextprotocol/sdkis a type import in the runtime template. The project that compiles the generated file supplies it.buildscript (tsc -p tsconfig.build.json) and aprepackhook that runs it. A manualnpm publishthus cannot ship an emptydist/.packages/openapi-codegen/src/*.ts: relative imports use.jsextensions, so that Node can resolve the emitted ESM.codegenreads the runtime template fromnew URL('../src/runtime.ts', import.meta.url). This path is correct fromsrc/(tests) and fromdist/(build). It replacesimport.meta.dirname, which needs Node 20.11. The package thus needs noenginesfloor. Yarn v1 enforcesengineson workspace packages, and CONTRIBUTING allows Node 20.0.packages/openapi-codegen/LICENSE: a copy of the root MIT license, so that the tarball carries it..github/workflows/ci.yml: new step. It packs the package, installs the tarball in an empty project outside the workspace, and callscodegenon a tiny OpenAPI document with plain Node..changeset/codegen-ship-dist.md: patch for@taskade/mcp-openapi-codegen. The public API (codegen) does not change.Subpath compatibility: 0.0.6 exported only
".", so no consumer can import a subpath."."keeps the same name and the samecodegenexport. deps.dev lists 0 dependent packages for 0.0.6.Contributor note: the server generator scripts now import the codegen from
dist/. Runyarn buildat the repo root. Lerna builds the codegen before the server, as CI and the release workflow do.Risk and rollback
codegenfunction and its output do not change. The server build gives byte-identicaltools.generated.ts,tools.v2.generated.tsandbin/cli.mjs.npm deprecate @taskade/mcp-openapi-codegen@<version> "<reason>".Tests
yarn testyarn lintrm -rf packages/openapi-codegen/dist && yarn buildbin/cli.mjs, before and aftergit diff --exit-codedist/dist/away, rungenerate:taskade-mcp-toolsCannot find module .../dist/index.js, as expectedrun:block fromci.yml, from an emptydist/codegen smoke test passednpm packLICENSE,README.md,package.json,dist/*.js,dist/*.d.ts,src/runtime.ts. No teststypescript,module: nodenext,skipLibCheck: falsetscpassesdereference('api.yaml'), thencodegen({ path, document }), thentscon the generated fileyarn install --frozen-lockfileCloses #94