Circular dependency issue
We're unable to build our mastra node/typescript service with a
mastra build command..d.ts file. Afaik the recommended setting here is .import { authMiddleware } from "@hive/lib-user/schemas";
import { Mastra } from "@mastra/core/mastra";
import { PinoLogger } from "@mastra/loggers";
import { insightsAgent } from "./agents/insights";
export const mastra = new Mastra({
agents: { insightsAgent },
logger: new PinoLogger({
name: "Mastra",
level: "info"
}),
observability: {
default: { enabled: true }
},
server: {
build: {
openAPIDocs: true,
swaggerUI: true
},
middleware: [authMiddleware]
},
bundler: {
externals: ["@hive/lib-user"],
sourcemap: true
}
});{
"name": "@hive/lib-user",
"version": "1.0.0",
"license": "UNLICENSED",
"private": true,
"source": "src/index.ts",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"source": "./src/index.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./authorization": {
"source": "./src/authorization/index.ts",
"require": "./dist/authorization.js",
"import": "./dist/authorization.mjs",
"types": "./dist/authorization.d.ts"
},
"./schemas": {
"source": "./src/schemas/index.ts",
"require": "./dist/schemas.js",
"import": "./dist/schemas.mjs",
"types": "./dist/schemas.d.ts"
},
"./mongoose": {
"source": "./src/mongoose/index.ts",
"require": "./dist/mongoose.js",
"import": "./dist/mongoose.mjs",
"types": "./dist/mongoose.d.ts"
}
},@hive/lib-user// tsconfig.base.json
{
"compilerOptions": {
"outDir": "${configDir}/dist",
"rootDirs": ["${configDir}/src"],
"typeRoots": [
"${configDir}/src/@types",
"${configDir}/node_modules/@types",
"node_modules/@types"
],
"lib": [
"es2024",
"ESNext.Array",
"ESNext.Collection",
"ESNext.Iterator",
"ESNext.Promise"
],
"target": "es2024",
"module": "commonjs",
"allowJs": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"useDefineForClassFields": true,
},
"include": ["${configDir}/src"],
"exclude": ["node_modules", "${configDir}/node_modules"]
}
// lib-user/tsconfig
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "esnext",
"declaration": true,
"emitDeclarationOnly": true
}
}"module": "commonjs""module": "bundler"commonjs{
code: 'ERROR',
error: Error [PLUGIN_ERROR]: Package subpath './a2a/store' is not defined by "exports" in /Users/bkniffler/GitHub/vrplatform/api/packages/mastra/node_modules/@mastra/server/package.json imported from /Users/bkniffler/GitHub/vrplatform/api/packages/mastra/node_modules/@mastra/deployer/dist/chunk-OFUWEVGF.js
at exportsNotFound (node:internal/modules/esm/resolve:322:10)
at packageExportsResolve (node:internal/modules/esm/resolve:670:9)
at packageResolve (node:internal/modules/esm/resolve:856:14)bun.lockimport { Mastra } from '@mastra/core';
import cors from 'cors';
import express from 'express';
import swaggerUi from 'swagger-ui-express';
import { ExpressServerAdapter } from '@mastra/express';
// define your Mastra instance
const mastra = new Mastra({
// ...
});
// define your express app
const app = express();
app.use(express.json());
app.use(cors());
// define your server adapter and register routes
const expressServerAdapter = new ExpressServerAdapter({ mastra });
expressServerAdapter.registerContextMiddleware(app);
await expressServerAdapter.registerRoutes(app, { openapiPath: '/openapi.json' });
// Add Swagger UI
app.use('/swagger-ui', swaggerUi.serve, swaggerUi.setup(undefined, { swaggerUrl: '/openapi.json' }));
app.listen(3001, () => {
console.info('Server is running on port 3001');
console.info('OpenAPI spec: http://localhost:3001/openapi.json');
console.info('Swagger UI: http://localhost:3001/swagger-ui');
});bun add @mastra/server@1.0.0-beta.5