Skip to content

fix: build mastra package export#57

Open
mojobeeping wants to merge 1 commit into
KeyValueSoftwareSystems:mainfrom
mojobeeping:mojobeep/build-mastra-export
Open

fix: build mastra package export#57
mojobeeping wants to merge 1 commit into
KeyValueSoftwareSystems:mainfrom
mojobeeping:mojobeep/build-mastra-export

Conversation

@mojobeeping

Copy link
Copy Markdown

Summary

The published @trysiren/agent-toolkit@0.2.0 package declares a ./mastra subpath export, but the published tarball does not include the target files under dist/mastra/*.

That makes this documented package entrypoint fail at runtime with ERR_MODULE_NOT_FOUND.

This PR adds src/mastra/index.ts to the tsup entry list so the dist/mastra bundle and declarations are generated, and externalizes the Mastra peer dependency the same way the OpenAI, LangChain, and AI SDK peer dependencies are handled.

Reproduction

tmpdir=$(mktemp -d)
cd "$tmpdir"
npm init -y >/dev/null
npm install --ignore-scripts @trysiren/agent-toolkit@0.2.0
node --input-type=module -e "import('@trysiren/agent-toolkit/mastra')"

Observed result from the published package:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module .../node_modules/@trysiren/agent-toolkit/dist/mastra/index.js

The package metadata points exports["./mastra"] at:

{
  "import": "./dist/mastra/index.js",
  "require": "./dist/mastra/index.js",
  "types": "./dist/mastra/index.d.ts"
}

But the published tarball has no dist/mastra files.

Validation

Ran from typescript/:

npm run build
npm run type-check
npm test -- --runInBand
git diff --check
NPM_CONFIG_CACHE=/tmp/mojobeep-npm-cache npm pack --json --ignore-scripts

The packed tarball now includes:

package/dist/mastra/index.js
package/dist/mastra/index.mjs
package/dist/mastra/index.d.ts
package/dist/mastra/index.d.mts

I also extracted the packed tarball into a clean temp directory and verified both loaders resolve the fixed entrypoint:

PATCHED_TRYSIREN_MASTRA_REQUIRE_OK SirenAgentToolkit,SirenTool
PATCHED_TRYSIREN_MASTRA_IMPORT_OK SirenAgentToolkit,SirenTool
PATCHED_TRYSIREN_MASTRA_FILES_OK

One unrelated check still fails before reaching changed files:

npm run lint
TypeError: Key "rules": Key "@typescript-eslint/prefer-const": Could not find "prefer-const" in plugin "@typescript-eslint". Did you mean "@/prefer-const"?

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