M
Mastra•6d ago
rachirib

Can I make `mastra` CLI transpile additional entrypoints?

I have the following setup
apps
|- mastra
|- src
|- mastra
|- agents
|- tools
|- types
|- workflows
|- index.ts
|- runWorkflows.ts
|- Dockerfile
apps
|- mastra
|- src
|- mastra
|- agents
|- tools
|- types
|- workflows
|- index.ts
|- runWorkflows.ts
|- Dockerfile
End goal is to do something like this on my Dockerfile
ENTRYPOINT ["node"]
CMD ["--import=./.mastra/output/instrumentation.mjs",".mastra/output/index.mjs"]
ENTRYPOINT ["node"]
CMD ["--import=./.mastra/output/instrumentation.mjs",".mastra/output/index.mjs"]
Then, be able to run a container with different commands, like
docker run --rm mastra ./mastra/output/runWorkflow.mjs
docker run --rm mastra ./mastra/output/runWorkflow.mjs
When I run mastra build it bundles everything index.mjs However, runWorkflows.ts is not transpiled, I tried workaround it by using just tsc & mastra build and try to emit files but that way it duplicates javascript files .mastra and dist at this point I feel going againts the tide ? any recommendations ?
3 Replies
LekoArts
LekoArts•6d ago
Hi 👋 Mastra only compiles code that is somewhere imported into the entrypoint (src/mastra/index.ts ) or used in one of the tools, agents, etc. There's no option to to compile additional files as one should do this on their own. You could use just-in-time compilation for your runWorkflow file, e.g. https://tsx.is/getting-started or in later node versions you can run it directy, too: https://nodejs.org/en/learn/typescript/run-natively
tsx
tsx
tsx (TypeScript Execute) - The easiest way to run TypeScript in Node.js
Node.js — Running TypeScript Natively
Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
Mastra Triager
Mastra Triager•6d ago
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10751 🔍 If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly. 🙏 Thank you for helping us improve Mastra!
rachirib
rachiribOP•5d ago
Thanks @LekoArts for your answer, I thought that was the case for mastra CLI, I'll try to make your suggestions work

Did you find this page helpful?