Skip to content

fix(codegen): publish built JavaScript with its runtime dependencies (#94) - #97

Merged
johnxie merged 2 commits into
mainfrom
build/codegen-ship-dist-94
Oct 22, 2026
Merged

johnxie merged 2 commits into
mainfrom
build/codegen-ship-dist-94

Conversation

@johnxie

@johnxie johnxie commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

@taskade/mcp-openapi-codegen 0.0.6 on npm cannot be imported after npm install. Its exports field points at raw TypeScript (./src/index.ts), and its runtime imports are only in devDependencies. This PR publishes built ESM JavaScript and .d.ts files from dist/ and lists the runtime imports in dependencies.

Failures on 0.0.6 (verified with the tarball from the public registry, Node 22):

node -e "import('@taskade/mcp-openapi-codegen')"
ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING Stripping types is currently unsupported for files under node_modules

npx tsx try.ts
ERR_MODULE_NOT_FOUND: Cannot find package 'json-schema-to-zod'

Changes

  • packages/openapi-codegen/tsconfig.build.json: new. tsc emits ESM JavaScript and .d.ts files to dist/. The tests and the runtime template are not compiled.
  • packages/openapi-codegen/package.json:
    • main, module, types and exports["."] point at dist/. exports also maps ./package.json.
    • files ships only dist/ and src/runtime.ts. npm adds the README and the LICENSE. The tests and tsconfig.json no longer ship.
    • json-schema-to-zod, prettier and openapi-types move to dependencies, with the ranges from the lockfile. openapi-types is a type-only import, but the public .d.ts refers to it.
    • @readme/openapi-parser and @modelcontextprotocol/sdk stay in devDependencies. 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/sdk is a type import in the runtime template. The project that compiles the generated file supplies it.
    • New build script (tsc -p tsconfig.build.json) and a prepack hook that runs it. A manual npm publish thus cannot ship an empty dist/.
  • packages/openapi-codegen/src/*.ts: relative imports use .js extensions, so that Node can resolve the emitted ESM. codegen reads the runtime template from new URL('../src/runtime.ts', import.meta.url). This path is correct from src/ (tests) and from dist/ (build). It replaces import.meta.dirname, which needs Node 20.11. The package thus needs no engines floor. Yarn v1 enforces engines on 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 calls codegen on 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 same codegen export. deps.dev lists 0 dependent packages for 0.0.6.

Contributor note: the server generator scripts now import the codegen from dist/. Run yarn build at the repo root. Lerna builds the codegen before the server, as CI and the release workflow do.

Risk and rollback

  • Risk is low. The codegen function and its output do not change. The server build gives byte-identical tools.generated.ts, tools.v2.generated.ts and bin/cli.mjs.
  • If the release breaks a consumer, revert this PR and publish a new patch. If the bad version must not be installed, run npm deprecate @taskade/mcp-openapi-codegen@<version> "<reason>".

Tests

Check Command Result
Unit tests yarn test 4 files, 19 tests pass
Lint yarn lint Pass
Full build rm -rf packages/openapi-codegen/dist && yarn build Pass. Lerna builds the codegen first
Server output unchanged md5 of the two generated files and bin/cli.mjs, before and after Identical
Clean tree after build git diff --exit-code Pass
Server uses dist/ Move dist/ away, run generate:taskade-mcp-tools Fails with Cannot find module .../dist/index.js, as expected
CI smoke step The exact run: block from ci.yml, from an empty dist/ codegen smoke test passed
Tarball contents npm pack LICENSE, README.md, package.json, dist/*.js, dist/*.d.ts, src/runtime.ts. No tests
Typed consumer Tarball + typescript, module: nodenext, skipLibCheck: false tsc passes
README flow dereference('api.yaml'), then codegen({ path, document }), then tsc on the generated file Pass
Lockfile yarn install --frozen-lockfile No change

Closes #94

…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
Copilot AI balanced review requested due to automatic review settings October 17, 2026 05:57
@changeset-bot

changeset-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ec96f7f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@taskade/mcp-openapi-codegen Patch

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.
@johnxie

johnxie commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Code review

No 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 engines.node >=20.11.0 for import.meta.dirname. Yarn v1 enforces engines on workspace packages, so yarn install failed on Node 20.0 to 20.10, which CONTRIBUTING allows. The template path now comes from new URL('../src/runtime.ts', import.meta.url), and the engines field is gone.

// The generated file inlines the runtime as TypeScript source. This module runs from
// src/ in the tests and from dist/ after a build. Both resolve ../src/runtime.ts.
const runtime = fs.readFileSync(
fileURLToPath(new URL('../src/runtime.ts', import.meta.url)),
'utf8',
);

@johnxie
johnxie requested a balanced review from Copilot October 17, 2026 06:02
@johnxie

johnxie commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

@deanzaka for review. This PR fixes the npm package @taskade/mcp-openapi-codegen.

Impact

  • Developers who install @taskade/mcp-openapi-codegen from npm can import it and generate MCP tools from their own OpenAPI spec. Today, the import fails on the published 0.0.6.
  • The tarball gets smaller and ships no test files.
  • CI now packs the package, installs the tarball in an empty project, and runs codegen. A broken tarball fails the PR before a release.
  • The @taskade/mcp-server build and its generated tools do not change.

Developer flow

Before (0.0.6):

npm i -D @taskade/mcp-openapi-codegen
  -> installs src/*.ts only, no JavaScript, no dependencies
node script.mjs  (import { codegen } from '@taskade/mcp-openapi-codegen')
  -> ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING  (exports -> ./src/index.ts)
npx tsx script.ts
  -> ERR_MODULE_NOT_FOUND: Cannot find package 'json-schema-to-zod'
  -> developer is stuck

After (next patch release):

npm i -D @taskade/mcp-openapi-codegen
  -> installs dist/*.js + dist/*.d.ts
  -> installs json-schema-to-zod, prettier, openapi-types as dependencies
node script.mjs  (import { codegen } from '@taskade/mcp-openapi-codegen')
  -> codegen({ document }) -> generated MCP tools source
tsc (module: nodenext)
  -> types resolve from dist/index.d.ts

Repo build (unchanged result):

yarn build -> lerna -> 1. codegen: tsc -> dist/
                       2. server:  generate tools (imports codegen dist/) -> build CLI -> lint:fix
           -> tools.generated.ts, tools.v2.generated.ts, bin/cli.mjs byte-identical to main

QA

Step Action Expected result
1 In the repo root, run yarn install --frozen-lockfile Install completes. The lockfile does not change
2 Run rm -rf packages/openapi-codegen/dist && yarn build Lerna builds the codegen first, then the server. git diff --exit-code passes
3 Regression: compare packages/server/src/tools.generated.ts, tools.v2.generated.ts and bin/cli.mjs with main The files are identical
4 Run yarn lint and yarn test Lint passes. 4 test files, 19 tests pass
5 In packages/openapi-codegen, run npm pack --pack-destination /tmp/cg The tarball holds dist/*.js, dist/*.d.ts, src/runtime.ts, README, LICENSE and package.json. No test files
6 In an empty dir outside the repo, run npm i /tmp/cg/taskade-mcp-openapi-codegen-*.tgz npm installs json-schema-to-zod, prettier and openapi-types
7 Run node --input-type=module -e "import('@taskade/mcp-openapi-codegen').then(m => console.log(typeof m.codegen))" Prints function
8 Call codegen({ document }) with a one-path OpenAPI document The output contains server.tool( for that path
9 In the same dir, add typescript and type-check an import with module: nodenext tsc --noEmit passes
10 CI: open the "Smoke test the packed codegen package" step on this PR The step prints codegen smoke test passed
11 Rollback: revert this PR and publish a new patch. If a bad version is out, run npm deprecate @taskade/mcp-openapi-codegen@<version> "<reason>" The previous package shape comes back. npm warns on the deprecated version

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The build, exports, dependencies, and template lookup are consistent, and the isolated smoke test covers the reported installation failure.

No open issues 🎉

Review effort: Balanced

@johnxie

johnxie commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Code review

No issues found. Checked head ec96f7f merged onto main 51a2577 for bugs, repo guidance (CONTRIBUTING.md), the history of the changed files, review comments on earlier PRs that touched them, and code-comment guidance.

@johnxie
johnxie merged commit b3e161f into main Oct 22, 2026
6 checks passed
@taskade-mcp-release taskade-mcp-release Bot mentioned this pull request Oct 22, 2026
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.

@taskade/mcp-openapi-codegen 0.0.6 ships raw TypeScript and cannot be imported after npm install

2 participants