@mastra/deployer 1.51.1-alpha.0 → 1.52.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/dist/build/analyze.cjs +2 -2
  3. package/dist/build/analyze.d.ts.map +1 -1
  4. package/dist/build/analyze.js +1 -1
  5. package/dist/build/babel/check-config-export.d.ts +2 -2
  6. package/dist/build/babel/check-config-export.d.ts.map +1 -1
  7. package/dist/build/babel/detect-pino-transports.d.ts +2 -2
  8. package/dist/build/babel/detect-pino-transports.d.ts.map +1 -1
  9. package/dist/build/babel/remove-all-options-except.d.ts +2 -2
  10. package/dist/build/babel/remove-all-options-except.d.ts.map +1 -1
  11. package/dist/build/babel/remove-deployer.d.ts +6 -2
  12. package/dist/build/babel/remove-deployer.d.ts.map +1 -1
  13. package/dist/build/babel/remove-non-referenced-nodes.d.ts +2 -2
  14. package/dist/build/babel/remove-non-referenced-nodes.d.ts.map +1 -1
  15. package/dist/build/bundler.cjs +5 -5
  16. package/dist/build/bundler.js +1 -1
  17. package/dist/build/index.cjs +22 -22
  18. package/dist/build/index.js +5 -5
  19. package/dist/build/plugins/remove-all-except.d.ts.map +1 -1
  20. package/dist/build/plugins/remove-deployer.d.ts.map +1 -1
  21. package/dist/build/plugins/remove-unused-references.d.ts.map +1 -1
  22. package/dist/bundler/index.cjs +3 -3
  23. package/dist/bundler/index.js +1 -1
  24. package/dist/{chunk-UFIOPABI.cjs → chunk-36AWZH7Z.cjs} +56 -90
  25. package/dist/chunk-36AWZH7Z.cjs.map +1 -0
  26. package/dist/{chunk-X2ZJLEWO.cjs → chunk-3XIMK24X.cjs} +22 -53
  27. package/dist/chunk-3XIMK24X.cjs.map +1 -0
  28. package/dist/{chunk-S32IJ4F6.js → chunk-3XJRELIX.js} +5 -5
  29. package/dist/{chunk-S32IJ4F6.js.map → chunk-3XJRELIX.js.map} +1 -1
  30. package/dist/{chunk-PLCERTF6.js → chunk-4ZFC5V33.js} +6 -6
  31. package/dist/{chunk-PLCERTF6.js.map → chunk-4ZFC5V33.js.map} +1 -1
  32. package/dist/{chunk-SZ3KU5RT.cjs → chunk-5ODCZKB7.cjs} +12 -12
  33. package/dist/{chunk-SZ3KU5RT.cjs.map → chunk-5ODCZKB7.cjs.map} +1 -1
  34. package/dist/{chunk-5K7ECKKW.js → chunk-5PORNUPF.js} +22 -35
  35. package/dist/chunk-5PORNUPF.js.map +1 -0
  36. package/dist/{chunk-JTWXTX2D.js → chunk-E5SBYHQK.js} +52 -68
  37. package/dist/chunk-E5SBYHQK.js.map +1 -0
  38. package/dist/{chunk-UY7KZXD2.js → chunk-EPALJ45Z.js} +12 -14
  39. package/dist/chunk-EPALJ45Z.js.map +1 -0
  40. package/dist/{chunk-VKAFARW6.cjs → chunk-FKKJQUGR.cjs} +4 -4
  41. package/dist/{chunk-VKAFARW6.cjs.map → chunk-FKKJQUGR.cjs.map} +1 -1
  42. package/dist/{chunk-2SUO6N5G.cjs → chunk-SYWSF3OR.cjs} +14 -14
  43. package/dist/{chunk-2SUO6N5G.cjs.map → chunk-SYWSF3OR.cjs.map} +1 -1
  44. package/dist/{chunk-7BDGRATY.cjs → chunk-YAIYFXQ6.cjs} +47 -49
  45. package/dist/chunk-YAIYFXQ6.cjs.map +1 -0
  46. package/dist/{chunk-ZL66GDLP.js → chunk-YUBKHO52.js} +2 -2
  47. package/dist/{chunk-ZL66GDLP.js.map → chunk-YUBKHO52.js.map} +1 -1
  48. package/dist/docs/SKILL.md +1 -1
  49. package/dist/docs/assets/SOURCE_MAP.json +5 -5
  50. package/dist/docs/references/docs-deployment-mastra-server.md +35 -0
  51. package/dist/docs/references/docs-deployment-monorepo.md +2 -0
  52. package/dist/docs/references/docs-deployment-overview.md +6 -0
  53. package/dist/index.cjs +11 -11
  54. package/dist/index.js +4 -4
  55. package/dist/server/handlers/agent-learning.d.ts +3 -0
  56. package/dist/server/handlers/agent-learning.d.ts.map +1 -0
  57. package/dist/server/index.cjs +68 -4
  58. package/dist/server/index.cjs.map +1 -1
  59. package/dist/server/index.d.ts.map +1 -1
  60. package/dist/server/index.js +66 -3
  61. package/dist/server/index.js.map +1 -1
  62. package/dist/services/index.cjs +4 -4
  63. package/dist/services/index.js +1 -1
  64. package/package.json +14 -16
  65. package/dist/chunk-5K7ECKKW.js.map +0 -1
  66. package/dist/chunk-7BDGRATY.cjs.map +0 -1
  67. package/dist/chunk-JTWXTX2D.js.map +0 -1
  68. package/dist/chunk-UFIOPABI.cjs.map +0 -1
  69. package/dist/chunk-UY7KZXD2.js.map +0 -1
  70. package/dist/chunk-X2ZJLEWO.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/plugins/esbuild.ts","../src/build/plugins/esm-shim.ts","../src/build/plugins/local-storage-detector.ts","../src/build/package-info.ts","../src/build/plugins/node-modules-extension-resolver.ts","../src/build/plugins/protocol-external-resolver.ts","../src/build/babel/remove-deployer.ts","../src/build/plugins/remove-deployer.ts","../src/build/plugins/subpath-externals-resolver.ts","../src/build/plugins/tsconfig-paths.ts","../src/build/bundler.ts"],"names":["t","path","removeDeployer","tsConfigPath","resolved","fileURLToPath","nodeResolve","join","pathToFileURL"],"mappings":";;;;;;;;;;;;;;;;;;;AAEO,SAAS,OAAA,CAAQ,OAAA,GAAiD,EAAC,EAAG;AAC3E,EAAA,OAAO,eAAA,CAAgB;AAAA,IACrB,MAAA,EAAQ,QAAA;AAAA,IACR,QAAA,EAAU,MAAA;AAAA,IACV,MAAA,EAAQ,KAAA;AAAA,IACR,GAAG;AAAA,GACJ,CAAA;AACH;ACJA,IAAM,wBAAA,GAA2B,gCAAA;AACjC,IAAM,uBAAA,GAA0B,+BAAA;AAYzB,SAAS,OAAA,GAAkB;AAChC,EAAA,MAAM,WAAW,eAAA,EAAgB;AAEjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,WAAA,CAAY,IAAA,EAAM,KA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A;AACA,EAAA,MAAM,OAAA,GAAU,MAAM,MAAA,CAAO,YAAY,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,OAAO,MAAM;AACX,MAAA,OAAO,QAAQ,KAAA,CAAM;AAAA,QACnB,GAAG,aAAA;AAAA,QACH,MAAA,EAAQ,KAAA;AAAA,QACR,cAAA,EAAgB,YAAA;AAAA,QAChB,cAAA,EAAgB;AAAA,OACjB,CAAA;AAAA,IACH,CAAA;AAAA,IACA,OAAO,MAAM;AACX,MAAA,OAAO,QAAQ,KAAA,EAAM;AAAA,IACvB;AAAA,GACF;AACF","file":"chunk-5PORNUPF.js","sourcesContent":["import originalEsbuild from 'rollup-plugin-esbuild';\n\nexport function esbuild(options: Parameters<typeof originalEsbuild>[0] = {}) {\n return originalEsbuild({\n target: 'node20',\n platform: 'node',\n minify: false,\n ...options,\n });\n}\n","import originalEsmShim from '@rollup/plugin-esm-shim';\nimport type { Plugin } from 'rollup';\n\n// Regex to detect DECLARATIONS of __filename, __dirname\n// Using non-capturing group (?:) for slightly better performance\nconst FilenameDeclarationRegex = /(?:const|let|var)\\s+__filename/;\nconst DirnameDeclarationRegex = /(?:const|let|var)\\s+__dirname/;\n\n/**\n * Custom ESM shim plugin wrapper that respects user-declared __filename/__dirname variables.\n *\n * The original @rollup/plugin-esm-shim would inject shims even when users had already declared\n * their own __filename/__dirname, causing \"Identifier '__filename' has already been declared\" errors.\n *\n * This wrapper checks if the user has already declared these variables and skips the shim injection\n * if so. If either variable is declared, we skip the shim entirely since the original plugin injects\n * both together and we assume users who declare one will also handle the other if needed.\n */\nexport function esmShim(): Plugin {\n const original = originalEsmShim();\n\n return {\n name: 'esm-shim',\n renderChunk(code, chunk, opts, meta) {\n // Fast path: use includes() first to avoid regex if identifiers aren't present\n const hasFilename = code.includes('__filename');\n const hasDirname = code.includes('__dirname');\n\n // If user declared either __filename or __dirname, skip shim injection entirely\n // since the original plugin injects both together\n const userDeclaredFilename = hasFilename && FilenameDeclarationRegex.test(code);\n const userDeclaredDirname = hasDirname && DirnameDeclarationRegex.test(code);\n\n if (userDeclaredFilename || userDeclaredDirname) {\n return null;\n }\n\n // Otherwise, delegate to the original plugin\n if (typeof original.renderChunk === 'function') {\n return original.renderChunk.call(this, code, chunk, opts, meta);\n }\n\n return null;\n },\n };\n}\n\nexport default esmShim;\n","import type { Plugin } from 'rollup';\n\n/**\n * Connection-string-shaped patterns that resolve to the build host and will\n * never work inside the deploy container.\n */\nconst LOCAL_HOST_PATTERNS: Array<{ pattern: RegExp; hint: string }> = [\n {\n pattern: /\\bfile:\\.{1,2}\\/[^\\s'\"`]+\\.(?:db|sqlite)\\b/gi,\n hint: 'LibSQL/SQLite file path relative to the build host',\n },\n {\n pattern: /\\b(?:postgres(?:ql)?|mysql|mongodb|redis|libsql):\\/\\/[^/\\s'\"`]*localhost\\b/gi,\n hint: 'localhost in a connection string',\n },\n {\n pattern: /\\b(?:postgres(?:ql)?|mysql|mongodb|redis|libsql):\\/\\/[^/\\s'\"`]*127\\.0\\.0\\.1\\b/g,\n hint: '127.0.0.1 in a connection string',\n },\n];\n\nexport interface LocalStorageDetection {\n value: string;\n hint: string;\n module: string;\n /**\n * Name of the env var that guards this literal at runtime, when the\n * literal is the fallback arm of a `process.env.X || literal` (or `??`)\n * expression. The CLI preflight uses this to suppress or soften the\n * error when the guarding var is present in the deploy env.\n */\n guardedBy?: string;\n}\n\n/**\n * Unified preflight metadata emitted as `preflight-metadata.json`.\n * Superset of the legacy `preflight-local-paths.json` (which stays emitted\n * for one release so older CLIs keep working with newer deployers).\n */\nexport interface PreflightMetadata {\n version: 1;\n localPaths: LocalStorageDetection[];\n userEnvRefs: string[];\n}\n\n/**\n * Everything under `.mastra/.build/` is deployer-generated pre-bundled\n * dependency code (`@mastra__*.mjs` shims and their shared `chunk-*.mjs`\n * files), never user-authored. These preserve JSDoc examples from the\n * original library source (e.g. `LibSQLStore({ url: 'file:./data.db' })`)\n * which would otherwise trip the host-local detector, and their env var\n * reads are library refs that must not count as user references.\n */\nconst MASTRA_BUILD_DIR = /[\\\\/]\\.mastra[\\\\/]\\.build[\\\\/]/;\n\nconst PROCESS_ENV_DOT = /\\bprocess\\.env\\.([A-Z_][A-Z0-9_]*)\\b/g;\nconst PROCESS_ENV_BRACKET = /\\bprocess\\.env\\[['\"]([A-Z_][A-Z0-9_]*)['\"]\\]/g;\n\n/** Names of the metadata assets emitted into the output dir. */\n// TODO(preflight-metadata): stop emitting the legacy file in the next minor\n// after @mastra/deployer 1.50 — every CLI released alongside 1.50+ reads\n// preflight-metadata.json. Also remove the legacy fallback in the CLI's\n// deploy-preflight.ts at the same time.\nconst LEGACY_LOCAL_PATHS_FILE = 'preflight-local-paths.json';\nconst PREFLIGHT_METADATA_FILE = 'preflight-metadata.json';\n\ninterface ModuleMatch {\n value: string;\n hint: string;\n guardedBy?: string;\n}\n\nfunction collectEnvRefs(code: string): Set<string> {\n const refs = new Set<string>();\n for (const m of code.matchAll(PROCESS_ENV_DOT)) refs.add(m[1]!);\n for (const m of code.matchAll(PROCESS_ENV_BRACKET)) refs.add(m[1]!);\n return refs;\n}\n\n/* ------------------------------------------------------------------ */\n/* AST guard analysis */\n/* ------------------------------------------------------------------ */\n\ninterface AstNode {\n type: string;\n [key: string]: unknown;\n}\n\nfunction isAstNode(v: unknown): v is AstNode {\n return typeof v === 'object' && v !== null && typeof (v as AstNode).type === 'string';\n}\n\nfunction walkAst(node: AstNode, visit: (node: AstNode) => void): void {\n visit(node);\n for (const value of Object.values(node)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (isAstNode(item)) walkAst(item, visit);\n }\n } else if (isAstNode(value)) {\n walkAst(value, visit);\n }\n }\n}\n\n/** Find the first `process.env.X` / `process.env['X']` read inside an expression. */\nfunction findFirstEnvRef(node: AstNode): string | undefined {\n let found: string | undefined;\n walkAst(node, n => {\n if (found !== undefined) return;\n if (n.type !== 'MemberExpression') return;\n const object = n.object as AstNode | undefined;\n if (\n !object ||\n object.type !== 'MemberExpression' ||\n (object.object as AstNode | undefined)?.type !== 'Identifier' ||\n ((object.object as AstNode).name as string) !== 'process' ||\n (object.property as AstNode | undefined)?.type !== 'Identifier' ||\n ((object.property as AstNode).name as string) !== 'env'\n ) {\n return;\n }\n const property = n.property as AstNode | undefined;\n if (property?.type === 'Identifier' && !n.computed) {\n found = property.name as string;\n } else if (property?.type === 'Literal' && typeof property.value === 'string') {\n found = property.value;\n }\n });\n return found;\n}\n\n/**\n * Parse a module and figure out, for each detected local-path value, whether\n * every string literal containing it is the fallback arm of a\n * `process.env.X || <literal>` / `??` expression. Returns a map from\n * detected value to guarding env var name. Values with any unguarded\n * occurrence (or inconsistent guards) are absent — the CLI then errors as\n * before, which is the safe default.\n */\nfunction findGuardedValues(ast: AstNode, values: Set<string>): Map<string, string> {\n const stringLiterals: AstNode[] = [];\n const guardedLiterals = new Map<AstNode, string>();\n\n walkAst(ast, node => {\n if (node.type === 'Literal' && typeof node.value === 'string') {\n stringLiterals.push(node);\n return;\n }\n if (node.type === 'LogicalExpression' && (node.operator === '||' || node.operator === '??')) {\n const right = node.right as AstNode | undefined;\n if (right?.type === 'Literal' && typeof right.value === 'string') {\n const envName = findFirstEnvRef(node.left as AstNode);\n if (envName) guardedLiterals.set(right, envName);\n }\n }\n });\n\n const result = new Map<string, string>();\n for (const value of values) {\n const containing = stringLiterals.filter(lit => (lit.value as string).includes(value));\n if (containing.length === 0) continue;\n const guards = containing.map(lit => guardedLiterals.get(lit));\n const first = guards[0];\n if (first !== undefined && guards.every(g => g === first)) {\n result.set(value, first);\n }\n }\n return result;\n}\n\n/**\n * Rollup plugin that detects host-local storage URLs (e.g. `file:./mastra.db`,\n * `postgres://localhost`) in **user source modules** during bundling, and\n * collects the env vars user code reads via `process.env.X`.\n *\n * Only modules outside `node_modules` (and the deployer's own\n * `.mastra/.build/` pre-bundled files) are inspected, so library code\n * (like Agent Builder prompt templates or JSDoc examples in `@mastra/core`)\n * is naturally excluded. When `rootDir` is given, modules outside it are\n * also excluded — symlinked dependencies (pnpm `link:`/`file:`) resolve to\n * real paths that never contain `node_modules`. Tree-shaken modules are\n * excluded via\n * `generateBundle` — only modules that actually contribute rendered code to\n * the output are reported.\n *\n * When a detected literal is the fallback arm of a `process.env.X || literal`\n * expression, `guardedBy: \"X\"` is recorded so the CLI preflight can apply\n * deploy-time env context instead of hard-erroring on a dead fallback.\n *\n * Two assets are emitted into the output directory for the CLI preflight:\n * - `preflight-metadata.json` — unified metadata (local paths + user env refs)\n * - `preflight-local-paths.json` — legacy shape, kept for one release so an\n * older globally-installed CLI paired with a newer project-local deployer\n * doesn't lose the LOCAL_STORAGE_PATH check.\n */\nexport function localStorageDetector(rootDir?: string): Plugin {\n const userModuleMatches = new Map<string, ModuleMatch[]>();\n const userModuleEnvRefs = new Map<string, Set<string>>();\n let normalizedRoot: string | undefined;\n if (rootDir) {\n let root = rootDir.replace(/\\\\/g, '/');\n while (root.endsWith('/')) root = root.slice(0, -1);\n normalizedRoot = root + '/';\n }\n\n return {\n name: 'mastra-local-storage-detector',\n\n transform(_code, id) {\n if (id.includes('node_modules')) return null;\n if (MASTRA_BUILD_DIR.test(id)) return null;\n // Modules outside the project/workspace root are dependencies resolved\n // through symlinks (pnpm `link:`, `file:`, monorepo dev setups) whose\n // real path escapes `node_modules` — library code, not user code.\n if (normalizedRoot && !id.replace(/\\\\/g, '/').startsWith(normalizedRoot)) return null;\n\n const refs = collectEnvRefs(_code);\n if (refs.size > 0) {\n userModuleEnvRefs.set(id, refs);\n }\n\n const matches: ModuleMatch[] = [];\n for (const { pattern, hint } of LOCAL_HOST_PATTERNS) {\n const re = new RegExp(pattern.source, pattern.flags.includes('g') ? pattern.flags : pattern.flags + 'g');\n for (const m of _code.matchAll(re)) {\n matches.push({ value: m[0], hint });\n }\n }\n\n if (matches.length > 0) {\n // Best-effort structural pass: a parse failure (or a non-Rollup test\n // context without `this.parse`) simply means no `guardedBy`, which\n // preserves the previous always-error behavior.\n try {\n const ast = this.parse(_code) as unknown as AstNode;\n const guarded = findGuardedValues(ast, new Set(matches.map(m => m.value)));\n for (const match of matches) {\n const guardedBy = guarded.get(match.value);\n if (guardedBy) match.guardedBy = guardedBy;\n }\n } catch {\n // ignore — fall back to unguarded detections\n }\n\n userModuleMatches.set(id, matches);\n }\n\n return null;\n },\n\n generateBundle(_, bundle) {\n const detections: LocalStorageDetection[] = [];\n const seen = new Set<string>();\n const userEnvRefs = new Set<string>();\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type !== 'chunk') continue;\n\n for (const [moduleId, moduleInfo] of Object.entries(chunk.modules)) {\n if (moduleInfo.renderedLength === 0) continue;\n\n for (const ref of userModuleEnvRefs.get(moduleId) ?? []) {\n userEnvRefs.add(ref);\n }\n\n const matches = userModuleMatches.get(moduleId);\n if (!matches) continue;\n\n for (const { value, hint, guardedBy } of matches) {\n const key = `${hint}::${value}`;\n if (seen.has(key)) continue;\n seen.add(key);\n\n detections.push({ value, hint, module: moduleId, ...(guardedBy ? { guardedBy } : {}) });\n }\n }\n }\n\n const metadata: PreflightMetadata = {\n version: 1,\n localPaths: detections,\n userEnvRefs: [...userEnvRefs].sort(),\n };\n\n this.emitFile({\n type: 'asset',\n fileName: PREFLIGHT_METADATA_FILE,\n source: JSON.stringify(metadata),\n });\n\n // Legacy asset — shape unchanged (no `guardedBy`) for older CLIs.\n this.emitFile({\n type: 'asset',\n fileName: LEGACY_LOCAL_PATHS_FILE,\n source: JSON.stringify(detections.map(({ value, hint, module }) => ({ value, hint, module }))),\n });\n },\n };\n}\n","/**\n * Note: This function depends on local-pkg and should only be used at build-time.\n * It is in a separate file to avoid including local-pkg in runtime code.\n */\n\nimport { statSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { readJSON } from 'fs-extra/esm';\nimport { getPackageInfo } from 'local-pkg';\nimport { getPackageName } from './utils';\n\n/**\n * Normalize a resolution base path to a directory file URL.\n *\n * Callers often pass a module file path (e.g. a rollup module id like\n * `node_modules/@mastra/core/dist/chunk-XYZ.js`) as the parent path. mlly (used by local-pkg)\n * also treats each resolution base as a directory candidate (`<base>/_index.js`), which makes it\n * try to read `<file>/package.json`. That fails with ENOTDIR, which mlly does not tolerate\n * (only ENOENT) and local-pkg then logs the raw error to the console. Using the file's directory\n * as the base avoids this while resolving identically.\n */\nfunction toParentDirectoryUrl(parentPath: string): string {\n let fsPath = parentPath.startsWith('file://') ? fileURLToPath(parentPath) : parentPath;\n\n try {\n if (statSync(fsPath).isFile()) {\n fsPath = dirname(fsPath);\n }\n } catch {\n // non-existent paths are used as-is\n }\n\n return pathToFileURL(fsPath).href;\n}\n\n/**\n * Get package root path\n */\nexport async function getPackageRootPath(packageName: string, parentPath?: string): Promise<string | null> {\n let rootPath: string | null;\n\n try {\n let options: { paths?: string[] } | undefined = undefined;\n if (parentPath) {\n options = {\n paths: [toParentDirectoryUrl(parentPath)],\n };\n }\n\n const pkg = await getPackageInfo(packageName, options);\n rootPath = pkg?.rootPath ?? null;\n } catch {\n rootPath = null;\n }\n\n return rootPath;\n}\n\nasync function readPackageMetadata(\n rootPath: string,\n requestedPackageName: string | null,\n): Promise<{ rootPath: string; version?: string; packageSpec?: string }> {\n try {\n const pkgJson = await readJSON(`${rootPath}/package.json`);\n const version = pkgJson.version;\n const actualPackageName = pkgJson.name;\n const packageSpec =\n version && actualPackageName && requestedPackageName && requestedPackageName !== actualPackageName\n ? `npm:${actualPackageName}@${version}`\n : undefined;\n\n return { rootPath, version, packageSpec };\n } catch {\n return { rootPath };\n }\n}\n\nexport async function getPackageMetadata(\n packageName: string,\n parentPath?: string,\n): Promise<{ rootPath: string | null; version?: string; packageSpec?: string }> {\n const requestedPackageName = getPackageName(packageName);\n const packageNames = [...new Set([packageName, requestedPackageName].filter(Boolean) as string[])];\n let firstRootPath: string | null = null;\n\n for (const name of packageNames) {\n const rootPath = await getPackageRootPath(name, parentPath);\n firstRootPath ??= rootPath;\n if (!rootPath) {\n continue;\n }\n\n const metadata = await readPackageMetadata(rootPath, requestedPackageName ?? null);\n if (metadata.version || metadata.packageSpec) {\n return metadata;\n }\n }\n\n return { rootPath: firstRootPath };\n}\n","import { readFile } from 'node:fs/promises';\nimport { join, isAbsolute } from 'node:path';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport type { Plugin } from 'rollup';\nimport type { PackageJson } from 'type-fest';\nimport { getPackageRootPath } from '../package-info';\nimport { getPackageName, isExternalProtocolImport, isBareModuleSpecifier } from '../utils';\n\n/**\n * Check if a package has an exports field in its package.json.\n * Results are cached to avoid repeated filesystem reads.\n */\nasync function getPackageJSON(pkgName: string, importer: string): Promise<PackageJson> {\n const pkgRoot = await getPackageRootPath(pkgName, importer);\n if (!pkgRoot) {\n throw new Error(`Package ${pkgName} not found`);\n }\n\n const pkgJSON = JSON.parse(await readFile(join(pkgRoot, 'package.json'), 'utf-8')) as PackageJson;\n return pkgJSON;\n}\n\n/**\n * Rollup plugin that resolves module extensions for external dependencies.\n *\n * This plugin handles ESM compatibility for external imports when node-resolve is not used:\n * - Packages WITH exports field (e.g., hono, date-fns): Keep imports as-is or strip redundant extensions\n * - Packages WITHOUT exports field (e.g., lodash): Add .js extension for direct file imports\n */\nexport function nodeModulesExtensionResolver(): Plugin {\n // Create a single instance of node-resolve to reuse\n const nodeResolvePlugin = nodeResolve();\n\n return {\n name: 'node-modules-extension-resolver',\n async resolveId(id, importer, options) {\n // Only bare package imports are relevant here.\n if (!importer || !isBareModuleSpecifier(id) || isExternalProtocolImport(id) || isAbsolute(id)) {\n return null;\n }\n\n // Skip direct package imports (e.g., 'lodash', '@mastra/core')\n const parts = id.split('/');\n const isScoped = id.startsWith('@');\n if ((isScoped && parts.length === 2) || (!isScoped && parts.length === 1)) {\n return null;\n }\n\n const pkgName = getPackageName(id);\n if (!pkgName) {\n return null;\n }\n\n try {\n const packageJSON = await getPackageJSON(pkgName, importer);\n // if it has exports, node should be able to rsolve it, if not the exports map is wrong.\n if (!!packageJSON.exports) {\n return null;\n }\n\n const packageRoot = await getPackageRootPath(pkgName, importer);\n // @ts-expect-error - handle is part of resolveId signature\n const nodeResolved = await nodeResolvePlugin.resolveId?.handler?.call(this, id, importer, options);\n // if we cannot resolve it, it's not a valid import so we let node handle it\n if (!nodeResolved?.id) {\n return null;\n }\n\n let filePath = nodeResolved.id;\n if (nodeResolved.resolvedBy === 'commonjs--resolver') {\n filePath = filePath.substring(1).split('?')[0];\n }\n\n const resolvedImportPath = filePath.replace(packageRoot, pkgName);\n\n return {\n id: resolvedImportPath,\n external: true,\n };\n } catch (err) {\n console.error(err);\n return null;\n }\n },\n };\n}\n","import type { Plugin } from 'rollup';\nimport { isExternalProtocolImport } from '../utils';\n\nexport function protocolExternalResolver({ exclude = ['node:'] }: { exclude?: readonly string[] } = {}): Plugin {\n return {\n name: 'protocol-external-resolver',\n resolveId(id) {\n if (!isExternalProtocolImport(id, exclude)) {\n return null;\n }\n\n return {\n id,\n external: true,\n };\n },\n } satisfies Plugin;\n}\n","import { types as t } from '@babel/core';\nimport type { NodePath, PluginObject, PluginPass } from '@babel/core';\n\ninterface RemoveDeployerState extends PluginPass {\n hasReplaced?: boolean;\n}\n\nexport function removeDeployer(): PluginObject<RemoveDeployerState> {\n // Helper to remove deployer property from an object and clean up its binding\n function removeDeployerFromObject(\n objectExpr: t.ObjectExpression,\n scope: { getBinding: (name: string) => { path?: NodePath } | undefined },\n ): t.ObjectProperty | undefined {\n const deployerProp = objectExpr.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === 'deployer',\n ) as t.ObjectProperty | undefined;\n\n if (deployerProp) {\n objectExpr.properties = objectExpr.properties.filter(prop => prop !== deployerProp);\n\n // Clean up the deployer binding if it's a reference\n if (t.isIdentifier(deployerProp.value)) {\n const deployerBinding = scope.getBinding(deployerProp.value.name);\n if (deployerBinding) {\n deployerBinding.path?.parentPath?.remove();\n }\n }\n }\n\n return deployerProp;\n }\n\n return {\n name: 'remove-deployer',\n visitor: {\n NewExpression(path, state: RemoveDeployerState) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n if (!state.hasReplaced) {\n state.hasReplaced = true;\n const newMastraObj = t.cloneNode(path.node);\n if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.length) {\n const objectArg = newMastraObj.arguments[0];\n let foundDeployer = false;\n\n // First, check for direct deployer property\n const directDeployer = removeDeployerFromObject(objectArg, state.file.scope);\n if (directDeployer) {\n foundDeployer = true;\n }\n\n // Then, check spread elements for deployer properties\n for (const prop of objectArg.properties) {\n if (t.isSpreadElement(prop) && t.isIdentifier(prop.argument)) {\n const spreadBinding = state.file.scope.getBinding(prop.argument.name);\n if (spreadBinding?.path && t.isVariableDeclarator(spreadBinding.path.node)) {\n const init = spreadBinding.path.node.init;\n if (t.isObjectExpression(init)) {\n const spreadDeployer = removeDeployerFromObject(init, state.file.scope);\n if (spreadDeployer) {\n foundDeployer = true;\n }\n }\n }\n }\n }\n\n if (foundDeployer) {\n path.replaceWith(newMastraObj);\n }\n }\n }\n },\n },\n } as PluginObject<RemoveDeployerState>;\n}\n","import { transformAsync } from '@babel/core';\nimport type { Plugin, SourceMapInput } from 'rollup';\n\nimport { removeDeployer as removeDeployerBabelPlugin } from '../babel/remove-deployer';\n\nexport function removeDeployer(mastraEntry: string, options?: { sourcemap?: boolean }): Plugin {\n return {\n name: 'remove-deployer',\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return transformAsync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [removeDeployerBabelPlugin],\n sourceMaps: options?.sourcemap,\n }).then(result => ({\n code: result!.code!,\n map: result!.map! as SourceMapInput,\n }));\n },\n } satisfies Plugin;\n}\n","import type { Plugin } from 'rollup';\nimport { isDependencyPartOfPackage } from '../utils';\n\nexport function subpathExternalsResolver(externals: string[]): Plugin {\n return {\n name: 'subpath-externals-resolver',\n resolveId(id) {\n if (id.startsWith('.') || id.startsWith('/')) {\n return null;\n }\n\n const isPartOfExternals = externals.some(external => isDependencyPartOfPackage(id, external));\n if (isPartOfExternals) {\n return {\n id,\n external: true,\n };\n }\n },\n } satisfies Plugin;\n}\n","import fs from 'node:fs';\nimport path, { normalize } from 'node:path';\nimport type { Plugin } from 'rollup';\nimport stripJsonComments from 'strip-json-comments';\nimport type { RegisterOptions } from 'typescript-paths';\nimport { createHandler } from 'typescript-paths';\n\nconst PLUGIN_NAME = 'tsconfig-paths';\nconst JS_IMPORT_SOURCE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];\n\nexport type PluginOptions = Omit<RegisterOptions, 'loggerID'> & { localResolve?: boolean };\n\n/**\n * Check if a tsconfig file has path mappings configured.\n * Exported for testing purposes.\n *\n * @param tsConfigPath - Path to the tsconfig.json file\n * @returns true if the tsconfig has paths configured or extends another config, false otherwise\n */\nexport function hasPaths(tsConfigPath: string): boolean {\n try {\n const content = fs.readFileSync(tsConfigPath, 'utf8');\n const config = JSON.parse(stripJsonComments(content));\n return !!(\n (config.compilerOptions?.paths && Object.keys(config.compilerOptions.paths).length > 0) ||\n (typeof config.extends === 'string' && config.extends.length > 0) ||\n (Array.isArray(config.extends) && config.extends.length > 0)\n );\n } catch {\n return false;\n }\n}\n\nexport function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve }: PluginOptions = {}): Plugin {\n const handlerCache = new Map<string, ReturnType<typeof createHandler>>();\n\n function resolveJsImportToSourceFile(moduleName: string): string {\n if (fs.existsSync(moduleName)) {\n return moduleName;\n }\n\n const parsed = path.parse(moduleName);\n if (parsed.ext !== '.js') {\n return moduleName;\n }\n\n for (const extension of JS_IMPORT_SOURCE_EXTENSIONS) {\n const candidate = path.join(parsed.dir, `${parsed.name}${extension}`);\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n }\n\n return moduleName;\n }\n\n // Find tsconfig.json file starting from a directory and walking up\n function findTsConfigForFile(filePath: string): string | null {\n let currentDir = path.dirname(filePath);\n const root = path.parse(currentDir).root;\n\n while (currentDir !== root) {\n const tsConfigPath = path.join(currentDir, 'tsconfig.json');\n\n if (fs.existsSync(tsConfigPath)) {\n // Check if this tsconfig has path mappings\n if (hasPaths(tsConfigPath)) {\n return tsConfigPath;\n }\n }\n\n // Also check for tsconfig.base.json (common in NX)\n const tsConfigBasePath = path.join(currentDir, 'tsconfig.base.json');\n if (fs.existsSync(tsConfigBasePath)) {\n if (hasPaths(tsConfigBasePath)) {\n return tsConfigBasePath;\n }\n }\n\n currentDir = path.dirname(currentDir);\n }\n\n return null;\n }\n\n // Get or create handler for a specific tsconfig file\n function getHandlerForFile(filePath: string): ReturnType<typeof createHandler> | null {\n // If a specific tsConfigPath was provided, use it\n if (tsConfigPath && typeof tsConfigPath === 'string') {\n if (!handlerCache.has(tsConfigPath)) {\n handlerCache.set(\n tsConfigPath,\n createHandler({\n log: () => {},\n tsConfigPath,\n respectCoreModule,\n falllback: moduleName => fs.existsSync(moduleName),\n }),\n );\n }\n return handlerCache.get(tsConfigPath)!;\n }\n\n // Find appropriate tsconfig for this file\n const configPath = findTsConfigForFile(filePath);\n if (!configPath) {\n return null;\n }\n\n // Cache handlers to avoid recreation\n if (!handlerCache.has(configPath)) {\n handlerCache.set(\n configPath,\n createHandler({\n log: () => {},\n tsConfigPath: configPath,\n respectCoreModule,\n falllback: moduleName => fs.existsSync(moduleName),\n }),\n );\n }\n\n return handlerCache.get(configPath)!;\n }\n\n // Simple alias resolution using dynamic handler\n function resolveAlias(request: string, importer: string): string | null | undefined {\n // Get the appropriate handler for this file\n const dynamicHandler = getHandlerForFile(importer);\n if (!dynamicHandler) {\n return null;\n }\n\n const resolved = dynamicHandler(request, normalize(importer));\n return resolved;\n }\n\n return {\n name: PLUGIN_NAME,\n resolveId: {\n order: 'pre',\n async handler(request, importer, options) {\n if (!importer || request.startsWith('\\0') || importer.charCodeAt(0) === 0) {\n return null;\n }\n\n // Convert relative paths to absolute to ensure proper tsconfig path resolution\n // This allows path aliases to work regardless of how the importer path is provided\n if (!path.isAbsolute(importer)) {\n importer = path.resolve(process.cwd(), importer);\n }\n\n const moduleName = resolveAlias(request, importer);\n // No tsconfig alias found, so we need to resolve it normally\n if (!moduleName) {\n const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });\n if (!resolved) {\n return null;\n }\n\n // If localResolve is true, we need to check if the importer has been resolved by the tsconfig-paths plugin\n // if so, we need to resolve the request from the importer instead of the root and mark it as external\n if (localResolve) {\n const importerInfo = this.getModuleInfo(importer);\n const importerPluginMeta = importerInfo?.meta?.[PLUGIN_NAME];\n\n if (!request.startsWith('./') && !request.startsWith('../') && importerPluginMeta?.resolved) {\n return {\n ...resolved,\n external: !request.startsWith('hono/') && request !== 'hono',\n };\n }\n }\n\n return {\n ...resolved,\n meta: {\n ...(resolved.meta || {}),\n },\n };\n }\n\n const resolvedModuleName = resolveJsImportToSourceFile(moduleName);\n\n // When a module does not have an extension, we need to resolve it to a file\n if (!path.extname(resolvedModuleName)) {\n const resolved = await this.resolve(resolvedModuleName, importer, { skipSelf: true, ...options });\n\n if (!resolved) {\n return null;\n }\n\n return {\n ...resolved,\n meta: {\n ...resolved.meta,\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n }\n\n // Always pass through bundler's resolution to ensure proper path normalization\n const resolved = await this.resolve(resolvedModuleName, importer, { skipSelf: true, ...options });\n\n if (!resolved) {\n return null;\n }\n\n return {\n ...resolved,\n meta: {\n ...resolved.meta,\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n },\n },\n } satisfies Plugin;\n}\n","import { join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport alias from '@rollup/plugin-alias';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport { rollup } from 'rollup';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport type { analyzeBundle } from './analyze';\nimport { esbuild } from './plugins/esbuild';\nimport { esmShim } from './plugins/esm-shim';\nimport { localStorageDetector } from './plugins/local-storage-detector';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { protocolExternalResolver } from './plugins/protocol-external-resolver';\nimport { removeDeployer } from './plugins/remove-deployer';\nimport { subpathExternalsResolver } from './plugins/subpath-externals-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport { getNodeResolveOptions, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport function mastraInternalAliasPlugin(entryFile: string): Plugin {\n const normalizedEntryFile = slash(entryFile);\n\n return alias({\n entries: [\n {\n find: /^\\#server$/,\n replacement: slash(fileURLToPath(import.meta.resolve('@mastra/deployer/server'))),\n },\n {\n find: /^\\@mastra\\/server\\/(.*)/,\n replacement: `@mastra/server/$1`,\n customResolver: id => {\n if (id.startsWith('@mastra/server')) {\n return {\n id: fileURLToPath(import.meta.resolve(id)),\n };\n }\n },\n },\n { find: /^\\#mastra$/, replacement: normalizedEntryFile },\n ],\n });\n}\n\nexport function mastraToolsAliasPlugin(): Plugin {\n return {\n name: 'tools-rewriter',\n resolveId(id: string) {\n if (id === '#tools') {\n return {\n id: './tools.mjs',\n external: true,\n };\n }\n },\n };\n}\n\nexport async function getInputOptions(\n entryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n platform: BundlerPlatform,\n env: Record<string, string> = { 'process.env.NODE_ENV': JSON.stringify('production') },\n {\n sourcemap = false,\n isDev = false,\n projectRoot,\n workspaceRoot = undefined,\n enableEsmShim = true,\n externalsPreset = false,\n }: {\n sourcemap?: boolean;\n isDev?: boolean;\n workspaceRoot?: string;\n projectRoot: string;\n enableEsmShim?: boolean;\n externalsPreset?: boolean;\n },\n): Promise<InputOptions> {\n const nodeResolvePlugin = nodeResolve(getNodeResolveOptions(platform));\n\n const externalsCopy = new Set<string>(analyzedBundleInfo.externalDependencies.keys());\n const externals = externalsPreset ? [] : Array.from(externalsCopy);\n\n return {\n logLevel: process.env.MASTRA_BUNDLER_DEBUG === 'true' ? 'debug' : 'silent',\n treeshake: 'smallest',\n preserveSymlinks: true,\n external: externals,\n plugins: [\n protocolExternalResolver(),\n subpathExternalsResolver(externals),\n {\n name: 'alias-optimized-deps',\n resolveId(id: string) {\n if (!analyzedBundleInfo.dependencies.has(id)) {\n return null;\n }\n\n const filename = analyzedBundleInfo.dependencies.get(id)!;\n const absolutePath = join(workspaceRoot || projectRoot, filename);\n\n // During `mastra dev` we want to keep deps as external\n if (isDev) {\n return {\n id: process.platform === 'win32' ? pathToFileURL(absolutePath).href : absolutePath,\n external: true,\n };\n }\n\n // For production builds return the absolute path as-is so Rollup can handle itself\n return {\n id: absolutePath,\n external: false,\n };\n },\n } satisfies Plugin,\n mastraInternalAliasPlugin(entryFile),\n tsConfigPaths(),\n mastraToolsAliasPlugin(),\n esbuild({\n platform,\n define: env,\n }),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n externalsPreset\n ? null\n : commonjs({\n extensions: ['.js', '.ts'],\n transformMixedEsModules: true,\n esmExternals(id) {\n return externals.includes(id);\n },\n }),\n enableEsmShim ? esmShim() : undefined,\n externalsPreset ? nodeModulesExtensionResolver() : nodeResolvePlugin,\n // for debugging\n // {\n // name: 'logger',\n // //@ts-expect-error\n // resolveId(id, ...args) {\n // console.log({ id, args });\n // },\n // // @ts-expect-error\n // transform(code, id) {\n // if (code.includes('class Duplexify ')) {\n // console.log({ duplex: id });\n // }\n // },\n // },\n json(),\n localStorageDetector(workspaceRoot || projectRoot),\n removeDeployer(entryFile, { sourcemap }),\n // treeshake unused imports\n esbuild({\n include: entryFile,\n platform,\n }),\n ].filter(Boolean),\n } satisfies InputOptions;\n}\n\nexport async function createBundler(\n inputOptions: InputOptions,\n outputOptions: Partial<OutputOptions> & { dir: string },\n) {\n const bundler = await rollup(inputOptions);\n\n return {\n write: () => {\n return bundler.write({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n });\n },\n close: () => {\n return bundler.close();\n },\n };\n}\n"]}
@@ -1,58 +1,64 @@
1
- import { tsConfigPaths, esbuild } from './chunk-5K7ECKKW.js';
1
+ import { tsConfigPaths, esbuild } from './chunk-5PORNUPF.js';
2
2
  import { pathToFileURL } from 'url';
3
3
  import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
4
4
  import commonjs from '@rollup/plugin-commonjs';
5
5
  import json from '@rollup/plugin-json';
6
6
  import { rollup } from 'rollup';
7
- import * as babel from '@babel/core';
8
- import babel__default from '@babel/core';
7
+ import { transformAsync, types } from '@babel/core';
9
8
 
10
9
  function removeAllOptionsFromMastraExcept(result, option, logger) {
11
- const t = babel__default.types;
12
10
  return {
13
11
  name: "remove-all-except-" + option + "-config",
14
12
  visitor: {
15
13
  ExportNamedDeclaration: {
16
- // remove all exports
14
+ // remove all exports, but keep the underlying declarations — the
15
+ // extracted option may reference them (e.g. `export const deployer = ...`
16
+ // used as `new Mastra({ deployer })`). Unreferenced declarations are
17
+ // dropped by the cleanup pass afterwards.
17
18
  exit(path) {
18
- path.remove();
19
+ if (path.node.declaration) {
20
+ const [declaration] = path.replaceWith(path.node.declaration);
21
+ declaration.skip();
22
+ } else {
23
+ path.remove();
24
+ }
19
25
  }
20
26
  },
21
27
  NewExpression(path, state) {
22
- const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
28
+ const varDeclaratorPath = path.findParent((path2) => types.isVariableDeclarator(path2.node));
23
29
  if (!varDeclaratorPath) {
24
30
  return;
25
31
  }
26
32
  const parentNode = path.parentPath.node;
27
- if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
33
+ if (!types.isVariableDeclarator(parentNode) || !types.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
28
34
  return;
29
35
  }
30
- let mastraArgs = t.objectExpression([]);
31
- if (t.isObjectExpression(path.node.arguments[0])) {
36
+ let mastraArgs = types.objectExpression([]);
37
+ if (types.isObjectExpression(path.node.arguments[0])) {
32
38
  mastraArgs = path.node.arguments[0];
33
39
  }
34
40
  let configProperty = mastraArgs.properties.find(
35
- (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option
41
+ (prop) => types.isObjectProperty(prop) && types.isIdentifier(prop.key) && prop.key.name === option
36
42
  );
37
- let configValue = t.objectExpression([]);
43
+ let configValue = types.objectExpression([]);
38
44
  const programPath = path.scope.getProgramParent().path;
39
45
  if (!programPath) {
40
46
  return;
41
47
  }
42
- if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {
48
+ if (configProperty && types.isObjectProperty(configProperty) && types.isExpression(configProperty.value)) {
43
49
  result.hasCustomConfig = true;
44
50
  configValue = configProperty.value;
45
- if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {
51
+ if (types.isIdentifier(configProperty.value) && configProperty.value.name === option) {
46
52
  const configBinding = state.file.scope.getBinding(option);
47
- if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {
53
+ if (configBinding && types.isVariableDeclarator(configBinding.path.node)) {
48
54
  const id = path.scope.generateUidIdentifier(option);
49
- configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init));
55
+ configBinding.path.replaceWith(types.variableDeclarator(id, configBinding.path.node.init));
50
56
  configValue = id;
51
57
  }
52
58
  }
53
59
  }
54
- const exportDeclaration = t.exportNamedDeclaration(
55
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]),
60
+ const exportDeclaration = types.exportNamedDeclaration(
61
+ types.variableDeclaration("const", [types.variableDeclarator(types.identifier(option), configValue)]),
56
62
  []
57
63
  );
58
64
  programPath.node.body.push(exportDeclaration);
@@ -69,8 +75,8 @@ function removeAllOptionsFromMastraExcept(result, option, logger) {
69
75
  details: "Please make sure your entry file looks like this:\nexport const mastra = new Mastra({\n <option>: <value>\n})"
70
76
  });
71
77
  }
72
- const fallbackExportDeclaration = t.exportNamedDeclaration(
73
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
78
+ const fallbackExportDeclaration = types.exportNamedDeclaration(
79
+ types.variableDeclaration("const", [types.variableDeclarator(types.identifier(option), types.objectExpression([]))]),
74
80
  []
75
81
  );
76
82
  path.node.body.push(fallbackExportDeclaration);
@@ -89,32 +95,20 @@ function removeAllOptionsFromMastraExceptPlugin(mastraEntry, name, result, optio
89
95
  if (id !== mastraEntry) {
90
96
  return;
91
97
  }
92
- return new Promise((resolve, reject) => {
93
- babel.transform(
94
- code,
95
- {
96
- babelrc: false,
97
- configFile: false,
98
- filename: id,
99
- plugins: [removeAllOptionsFromMastraExcept(result, name, options?.logger)],
100
- sourceMaps: options?.sourcemap
101
- },
102
- (err, result2) => {
103
- if (err) {
104
- return reject(err);
105
- }
106
- resolve({
107
- code: result2.code,
108
- map: result2.map
109
- });
110
- }
111
- );
112
- });
98
+ return transformAsync(code, {
99
+ babelrc: false,
100
+ configFile: false,
101
+ filename: id,
102
+ plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],
103
+ sourceMaps: options?.sourcemap
104
+ }).then((result2) => ({
105
+ code: result2.code,
106
+ map: result2.map
107
+ }));
113
108
  }
114
109
  };
115
110
  }
116
111
  function removeNonReferencedNodes() {
117
- const t = babel__default.types;
118
112
  return {
119
113
  name: "remove-non-referenced-nodes",
120
114
  visitor: {
@@ -127,7 +121,7 @@ function removeNonReferencedNodes() {
127
121
  }
128
122
  if (childPath.isVariableDeclaration()) {
129
123
  return childPath.node.declarations.some((decl) => {
130
- if (!t.isIdentifier(decl.id)) {
124
+ if (!types.isIdentifier(decl.id)) {
131
125
  return false;
132
126
  }
133
127
  const name = decl.id.name;
@@ -136,7 +130,7 @@ function removeNonReferencedNodes() {
136
130
  });
137
131
  }
138
132
  if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
139
- if (!t.isIdentifier(childPath.node.id)) {
133
+ if (!types.isIdentifier(childPath.node.id)) {
140
134
  return false;
141
135
  }
142
136
  const name = childPath.node.id.name;
@@ -162,29 +156,19 @@ function removeNonReferencedNodes() {
162
156
  }
163
157
 
164
158
  // src/build/plugins/remove-unused-references.ts
165
- function recursiveRemoveNonReferencedNodes(code) {
166
- return new Promise(async (resolve, reject) => {
167
- babel.transform(
168
- code,
169
- {
170
- babelrc: false,
171
- configFile: false,
172
- plugins: [removeNonReferencedNodes()]
173
- },
174
- (err, result) => {
175
- if (err) {
176
- return reject(err);
177
- }
178
- if (result && result.code !== code) {
179
- return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
180
- }
181
- resolve({
182
- code: result.code,
183
- map: result.map
184
- });
185
- }
186
- );
159
+ async function recursiveRemoveNonReferencedNodes(code) {
160
+ const result = await transformAsync(code, {
161
+ babelrc: false,
162
+ configFile: false,
163
+ plugins: [removeNonReferencedNodes]
187
164
  });
165
+ if (result && result.code !== code) {
166
+ return recursiveRemoveNonReferencedNodes(result.code);
167
+ }
168
+ return {
169
+ code: result.code,
170
+ map: result.map
171
+ };
188
172
  }
189
173
 
190
174
  // src/build/shared/extract-mastra-option.ts
@@ -256,5 +240,5 @@ async function getBundlerOptions(entryFile, outputDir, logger) {
256
240
  }
257
241
 
258
242
  export { extractMastraOption, getBundlerOptions };
259
- //# sourceMappingURL=chunk-JTWXTX2D.js.map
260
- //# sourceMappingURL=chunk-JTWXTX2D.js.map
243
+ //# sourceMappingURL=chunk-E5SBYHQK.js.map
244
+ //# sourceMappingURL=chunk-E5SBYHQK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/babel/remove-all-options-except.ts","../src/build/plugins/remove-all-except.ts","../src/build/babel/remove-non-referenced-nodes.ts","../src/build/plugins/remove-unused-references.ts","../src/build/shared/extract-mastra-option.ts","../src/build/bundlerOptions.ts"],"names":["path","t","result","transformAsync"],"mappings":";;;;;;;;AAKO,SAAS,gCAAA,CACd,MAAA,EACA,MAAA,EACA,MAAA,EACc;AACd,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,uBAAuB,MAAA,GAAS,SAAA;AAAA,IACtC,OAAA,EAAS;AAAA,MACP,sBAAA,EAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,QAKtB,KAAK,IAAA,EAAM;AACT,UAAA,IAAI,IAAA,CAAK,KAAK,WAAA,EAAa;AACzB,YAAA,MAAM,CAAC,WAAW,CAAA,GAAI,KAAK,WAAA,CAAY,IAAA,CAAK,KAAK,WAAW,CAAA;AAG5D,YAAA,WAAA,CAAY,IAAA,EAAK;AAAA,UACnB,CAAA,MAAO;AACL,YAAA,IAAA,CAAK,MAAA,EAAO;AAAA,UACd;AAAA,QACF;AAAA,OACF;AAAA,MAEA,aAAA,CAAc,MAAM,KAAA,EAAO;AAEzB,QAAA,MAAM,iBAAA,GAAoB,KAAK,UAAA,CAAW,CAAAA,UAAQC,KAAA,CAAE,oBAAA,CAAqBD,KAAAA,CAAK,IAAI,CAAC,CAAA;AACnF,QAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,UAAA;AAAA,QACF;AAEA,QAAA,MAAM,UAAA,GAAa,KAAK,UAAA,CAAW,IAAA;AAEnC,QAAA,IAAI,CAACC,KAAA,CAAE,oBAAA,CAAqB,UAAU,KAAK,CAACA,KAAA,CAAE,YAAA,CAAa,UAAA,CAAW,EAAE,CAAA,IAAK,UAAA,CAAW,EAAA,CAAG,SAAS,QAAA,EAAU;AAC5G,UAAA;AAAA,QACF;AAEA,QAAA,IAAI,UAAA,GAAaA,KAAA,CAAE,gBAAA,CAAiB,EAAE,CAAA;AACtC,QAAA,IAAIA,MAAE,kBAAA,CAAmB,IAAA,CAAK,KAAK,SAAA,CAAU,CAAC,CAAC,CAAA,EAAG;AAChD,UAAA,UAAA,G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,EAAU;AAC1B","file":"chunk-E5SBYHQK.js","sourcesContent":["import { types as t } from '@babel/core';\nimport type { NodePath, PluginObject, types } from '@babel/core';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\n\nexport function removeAllOptionsFromMastraExcept(\n result: { hasCustomConfig: boolean },\n option: keyof MastraConfig,\n logger?: IMastraLogger,\n): PluginObject {\n return {\n name: 'remove-all-except-' + option + '-config',\n visitor: {\n ExportNamedDeclaration: {\n // remove all exports, but keep the underlying declarations — the\n // extracted option may reference them (e.g. `export const deployer = ...`\n // used as `new Mastra({ deployer })`). Unreferenced declarations are\n // dropped by the cleanup pass afterwards.\n exit(path) {\n if (path.node.declaration) {\n const [declaration] = path.replaceWith(path.node.declaration);\n // Already traversed — don't requeue, or the NewExpression visitor\n // would append the extracted export a second time.\n declaration.skip();\n } else {\n path.remove();\n }\n },\n },\n\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n let mastraArgs = t.objectExpression([]);\n if (t.isObjectExpression(path.node.arguments[0])) {\n mastraArgs = path.node.arguments[0];\n }\n\n // Find the config property, skipping SpreadElement nodes\n let configProperty = mastraArgs.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option,\n );\n let configValue: types.Expression = t.objectExpression([]);\n\n const programPath = path.scope.getProgramParent().path as NodePath<types.Program> | undefined;\n if (!programPath) {\n return;\n }\n\n if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {\n result.hasCustomConfig = true;\n configValue = configProperty.value;\n\n if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {\n const configBinding = state.file.scope.getBinding(option)!;\n\n if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {\n const id = path.scope.generateUidIdentifier(option);\n\n configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init!));\n configValue = id;\n }\n }\n }\n\n // add the deployer export\n const exportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), configValue)]),\n [],\n );\n\n programPath.node.body.push(exportDeclaration);\n },\n\n Program: {\n exit(path) {\n // Add a fallback export if no mastra configuration was found\n const hasExport = path.node.body.some(\n node => node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration',\n );\n\n if (!hasExport) {\n if (logger) {\n logger.warn('Mastra config could not be extracted', {\n option,\n details:\n 'Please make sure your entry file looks like this:\\nexport const mastra = new Mastra({\\n <option>: <value>\\n})',\n });\n }\n\n const fallbackExportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),\n [],\n );\n path.node.body.push(fallbackExportDeclaration);\n }\n },\n },\n },\n } satisfies PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport type { Plugin, SourceMapInput } from 'rollup';\nimport { removeAllOptionsFromMastraExcept } from '../babel/remove-all-options-except';\n\nexport function removeAllOptionsFromMastraExceptPlugin(\n mastraEntry: string,\n name: keyof MastraConfig,\n result: { hasCustomConfig: boolean },\n options?: { sourcemap?: boolean; logger?: IMastraLogger },\n): Plugin {\n return {\n name: `remove-${name}`,\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return transformAsync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],\n sourceMaps: options?.sourcemap,\n }).then(result => ({\n code: result!.code!,\n map: result!.map! as SourceMapInput,\n }));\n },\n } satisfies Plugin;\n}\n","import { types as t } from '@babel/core';\nimport type { PluginObject } from '@babel/core';\n\nexport function removeNonReferencedNodes() {\n return {\n name: 'remove-non-referenced-nodes',\n visitor: {\n Program(path) {\n // Get the scope information\n const scope = path.scope;\n\n // Filter body to keep only referenced nodes\n const currentBody = path.get('body');\n const filteredBody = currentBody.filter(childPath => {\n if (childPath.isExportDeclaration()) {\n return true;\n }\n\n // For variable declarations, check if any declared variables are referenced\n if (childPath.isVariableDeclaration()) {\n return childPath.node.declarations.some(decl => {\n if (!t.isIdentifier(decl.id)) {\n return false;\n }\n\n const name = decl.id.name;\n const binding = scope.getBinding(name);\n // Keep if it has references or is exported\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // For function/class declarations, check if they're referenced\n if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {\n if (!t.isIdentifier(childPath.node.id)) {\n return false;\n }\n\n const name = childPath.node.id.name;\n const binding = scope.getBinding(name);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n }\n\n // For imports, check if any imported items are referenced\n if (childPath.isImportDeclaration()) {\n return childPath.node.specifiers.some(specifier => {\n const importedName = specifier.local.name;\n const binding = scope.getBinding(importedName);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // Default to keeping other node types\n return false;\n });\n\n // Replace the program body with filtered nodes\n path.set(\n 'body',\n filteredBody.map(p => p.node),\n );\n },\n },\n } as PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport { removeNonReferencedNodes } from '../babel/remove-non-referenced-nodes';\n\nexport async function recursiveRemoveNonReferencedNodes(code: string): Promise<{ code: string; map: any }> {\n const result = await transformAsync(code, {\n babelrc: false,\n configFile: false,\n plugins: [removeNonReferencedNodes],\n });\n\n // keep looping until the code is not changed\n if (result && result.code! !== code) {\n return recursiveRemoveNonReferencedNodes(result!.code!);\n }\n\n return {\n code: result!.code!,\n map: result!.map!,\n };\n}\n","import { pathToFileURL } from 'node:url';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport { rollup } from 'rollup';\nimport type { RollupOutput } from 'rollup';\nimport { esbuild } from '../plugins/esbuild';\nimport { removeAllOptionsFromMastraExceptPlugin } from '../plugins/remove-all-except';\nimport { recursiveRemoveNonReferencedNodes } from '../plugins/remove-unused-references';\nimport { tsConfigPaths } from '../plugins/tsconfig-paths';\n\nexport function extractMastraOptionBundler(\n name: keyof MastraConfig,\n entryFile: string,\n result: {\n hasCustomConfig: boolean;\n },\n logger?: IMastraLogger,\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n [`${name}-config`]: entryFile,\n },\n treeshake: 'smallest',\n plugins: [\n tsConfigPaths(),\n // transpile typescript to something we understand\n esbuild(),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n json(),\n removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),\n // let esbuild remove all unused imports\n esbuild(),\n {\n name: 'cleanup',\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return recursiveRemoveNonReferencedNodes(code);\n },\n },\n // let esbuild remove it once more\n esbuild(),\n ],\n });\n}\n\nexport async function extractMastraOption<T extends keyof MastraConfig>(\n name: T,\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{\n bundleOutput: RollupOutput;\n getConfig: () => Promise<MastraConfig[T]>;\n} | null> {\n const result = {\n hasCustomConfig: false,\n };\n\n const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);\n\n const output = await bundler.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n });\n\n if (result.hasCustomConfig) {\n const configPath = `${outputDir}/${name}-config.mjs`;\n\n return {\n bundleOutput: output,\n getConfig: () => import(pathToFileURL(configPath).href).then(m => m[name] as MastraConfig[T]),\n };\n }\n\n return null;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getBundlerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('bundler', entryFile, result);\n}\n\nexport async function getBundlerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['bundler'] | null> {\n const result = await extractMastraOption('bundler', entryFile, outputDir, logger);\n\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"]}
@@ -1,11 +1,10 @@
1
- import { getPackageMetadata, protocolExternalResolver, mastraInternalAliasPlugin, mastraToolsAliasPlugin, tsConfigPaths, esbuild, removeDeployer, getPackageRootPath, subpathExternalsResolver, esmShim } from './chunk-5K7ECKKW.js';
1
+ import { getPackageMetadata, protocolExternalResolver, mastraInternalAliasPlugin, mastraToolsAliasPlugin, tsConfigPaths, esbuild, removeDeployer, getPackageRootPath, subpathExternalsResolver, esmShim } from './chunk-5PORNUPF.js';
2
2
  import { slash, isDependencyPartOfPackage, getPackageName, isBuiltinModule, isBareModuleSpecifier, isExternalProtocolImport, getCompiledDepCachePath, rollupSafeName, getNodeResolveOptions } from './chunk-WP65JQAT.js';
3
3
  import { existsSync } from 'fs';
4
4
  import { readFile, writeFile } from 'fs/promises';
5
5
  import * as path from 'path';
6
6
  import { dirname, join, relative, isAbsolute, basename as basename$1 } from 'path';
7
- import * as babel2 from '@babel/core';
8
- import babel2__default, { types } from '@babel/core';
7
+ import { transformAsync, transformSync, types } from '@babel/core';
9
8
  import { MastraBaseError, ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
10
9
  import * as pkg from 'empathic/package';
11
10
  import { createWorkspacesCache, findWorkspaces, findWorkspacesRoot } from 'find-workspaces';
@@ -936,21 +935,20 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
936
935
  return { output, fileNameToDependencyMap, usedExternals };
937
936
  }
938
937
  function checkConfigExport(result) {
939
- const t2 = babel2__default.types;
940
938
  const mastraVars = /* @__PURE__ */ new Set();
941
939
  return {
942
940
  visitor: {
943
941
  ExportNamedDeclaration(path2) {
944
942
  const decl = path2.node.declaration;
945
- if (t2.isVariableDeclaration(decl)) {
943
+ if (types.isVariableDeclaration(decl)) {
946
944
  const varDecl = decl.declarations[0];
947
- if (t2.isIdentifier(varDecl?.id, { name: "mastra" }) && t2.isNewExpression(varDecl.init) && t2.isIdentifier(varDecl.init.callee, { name: "Mastra" })) {
945
+ if (types.isIdentifier(varDecl?.id, { name: "mastra" }) && types.isNewExpression(varDecl.init) && types.isIdentifier(varDecl.init.callee, { name: "Mastra" })) {
948
946
  result.hasValidConfig = true;
949
947
  }
950
948
  }
951
949
  if (Array.isArray(path2.node.specifiers)) {
952
950
  for (const spec of path2.node.specifiers) {
953
- if (t2.isExportSpecifier(spec) && t2.isIdentifier(spec.exported, { name: "mastra" }) && t2.isIdentifier(spec.local) && mastraVars.has(spec.local.name)) {
951
+ if (types.isExportSpecifier(spec) && types.isIdentifier(spec.exported, { name: "mastra" }) && types.isIdentifier(spec.local) && mastraVars.has(spec.local.name)) {
954
952
  result.hasValidConfig = true;
955
953
  }
956
954
  }
@@ -959,7 +957,7 @@ function checkConfigExport(result) {
959
957
  // For cases 2-4 we need to track whether those variables are assigned to `new Mastra()`
960
958
  VariableDeclaration(path2) {
961
959
  for (const decl of path2.node.declarations) {
962
- if (t2.isIdentifier(decl.id) && t2.isNewExpression(decl.init) && t2.isIdentifier(decl.init.callee, { name: "Mastra" })) {
960
+ if (types.isIdentifier(decl.id) && types.isNewExpression(decl.init) && types.isIdentifier(decl.init.callee, { name: "Mastra" })) {
963
961
  mastraVars.add(decl.id.name);
964
962
  }
965
963
  }
@@ -1321,10 +1319,10 @@ async function analyzeBundle(entries, mastraEntry, {
1321
1319
  const mastraConfigResult = {
1322
1320
  hasValidConfig: false
1323
1321
  };
1324
- await babel2.transformAsync(mastraConfig, {
1322
+ await transformAsync(mastraConfig, {
1325
1323
  filename: mastraEntry,
1326
1324
  presets: [import.meta.resolve("@babel/preset-typescript")],
1327
- plugins: [checkConfigExport(mastraConfigResult)]
1325
+ plugins: [() => checkConfigExport(mastraConfigResult)]
1328
1326
  });
1329
1327
  if (!mastraConfigResult.hasValidConfig) {
1330
1328
  logger.warn("Invalid Mastra config", {
@@ -1355,9 +1353,9 @@ async function analyzeBundle(entries, mastraEntry, {
1355
1353
  shouldCheckTransitiveDependencies: true,
1356
1354
  analyzeCache
1357
1355
  });
1358
- babel2.transformSync(analyzeResult.output.code, {
1356
+ transformSync(analyzeResult.output.code, {
1359
1357
  filename: "pino-detection.js",
1360
- plugins: [detectPinoTransports(detectedPinoTransports)],
1358
+ plugins: [() => detectPinoTransports(detectedPinoTransports)],
1361
1359
  configFile: false,
1362
1360
  babelrc: false,
1363
1361
  code: false
@@ -1504,5 +1502,5 @@ async function analyzeBundle(entries, mastraEntry, {
1504
1502
  }
1505
1503
 
1506
1504
  export { aliasHono, analyzeBundle, getWorkspaceInformation };
1507
- //# sourceMappingURL=chunk-UY7KZXD2.js.map
1508
- //# sourceMappingURL=chunk-UY7KZXD2.js.map
1505
+ //# sourceMappingURL=chunk-EPALJ45Z.js.map
1506
+ //# sourceMappingURL=chunk-EPALJ45Z.js.map