@mastra/deployer 0.16.0-alpha.1 → 0.16.1-alpha.0

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 (68) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/build/analyze.cjs +3 -3
  3. package/dist/build/analyze.d.ts +5 -7
  4. package/dist/build/analyze.d.ts.map +1 -1
  5. package/dist/build/analyze.js +1 -1
  6. package/dist/build/bundler.cjs +3 -3
  7. package/dist/build/bundler.d.ts +4 -2
  8. package/dist/build/bundler.d.ts.map +1 -1
  9. package/dist/build/bundler.js +1 -1
  10. package/dist/build/index.cjs +19 -19
  11. package/dist/build/index.js +5 -5
  12. package/dist/build/types.d.ts +18 -0
  13. package/dist/build/types.d.ts.map +1 -0
  14. package/dist/build/utils.d.ts +5 -0
  15. package/dist/build/utils.d.ts.map +1 -1
  16. package/dist/build/watcher.d.ts.map +1 -1
  17. package/dist/bundler/index.cjs +2 -2
  18. package/dist/bundler/index.js +1 -1
  19. package/dist/bundler/workspaceDependencies.d.ts.map +1 -1
  20. package/dist/{chunk-IVGJKJCG.js → chunk-4CAKOUIN.js} +21 -10
  21. package/dist/chunk-4CAKOUIN.js.map +1 -0
  22. package/dist/{chunk-HUAOVISC.js → chunk-5ZHIZCMJ.js} +209 -58
  23. package/dist/chunk-5ZHIZCMJ.js.map +1 -0
  24. package/dist/{chunk-AM2S5WCK.cjs → chunk-HR2HOA5D.cjs} +10 -6
  25. package/dist/chunk-HR2HOA5D.cjs.map +1 -0
  26. package/dist/{chunk-HFSNFLSA.cjs → chunk-JOCAZKZ5.cjs} +22 -9
  27. package/dist/chunk-JOCAZKZ5.cjs.map +1 -0
  28. package/dist/{chunk-U4ZNNX34.js → chunk-LL2SXZRQ.js} +3 -3
  29. package/dist/{chunk-U4ZNNX34.js.map → chunk-LL2SXZRQ.js.map} +1 -1
  30. package/dist/{chunk-LQCSOGOC.js → chunk-LN4WTW4C.js} +18 -5
  31. package/dist/chunk-LN4WTW4C.js.map +1 -0
  32. package/dist/{chunk-2GPZM6PP.js → chunk-MAPVVNYR.js} +6 -7
  33. package/dist/chunk-MAPVVNYR.js.map +1 -0
  34. package/dist/{chunk-FOPPWICF.cjs → chunk-OBHT43LS.cjs} +20 -21
  35. package/dist/chunk-OBHT43LS.cjs.map +1 -0
  36. package/dist/{chunk-WHMSFLP7.cjs → chunk-PX6ZHD5K.cjs} +5 -5
  37. package/dist/{chunk-WHMSFLP7.cjs.map → chunk-PX6ZHD5K.cjs.map} +1 -1
  38. package/dist/{chunk-KVBYKVQQ.cjs → chunk-T4L3WY7M.cjs} +223 -65
  39. package/dist/chunk-T4L3WY7M.cjs.map +1 -0
  40. package/dist/{chunk-DG6YR6QC.js → chunk-YOULDYHE.js} +8 -4
  41. package/dist/chunk-YOULDYHE.js.map +1 -0
  42. package/dist/{chunk-WSYCRXET.cjs → chunk-ZQJDMTCN.cjs} +29 -18
  43. package/dist/chunk-ZQJDMTCN.cjs.map +1 -0
  44. package/dist/index.cjs +12 -12
  45. package/dist/index.js +4 -4
  46. package/dist/server/index.cjs +1 -1
  47. package/dist/server/index.cjs.map +1 -1
  48. package/dist/server/index.js +1 -1
  49. package/dist/server/index.js.map +1 -1
  50. package/dist/services/deps.d.ts +2 -1
  51. package/dist/services/deps.d.ts.map +1 -1
  52. package/dist/services/index.cjs +4 -4
  53. package/dist/services/index.js +1 -1
  54. package/package.json +7 -7
  55. package/dist/chunk-2GPZM6PP.js.map +0 -1
  56. package/dist/chunk-AM2S5WCK.cjs.map +0 -1
  57. package/dist/chunk-DG6YR6QC.js.map +0 -1
  58. package/dist/chunk-FOPPWICF.cjs.map +0 -1
  59. package/dist/chunk-HFSNFLSA.cjs.map +0 -1
  60. package/dist/chunk-HUAOVISC.js.map +0 -1
  61. package/dist/chunk-IKIYTFYW.js +0 -163
  62. package/dist/chunk-IKIYTFYW.js.map +0 -1
  63. package/dist/chunk-IVGJKJCG.js.map +0 -1
  64. package/dist/chunk-KVBYKVQQ.cjs.map +0 -1
  65. package/dist/chunk-LQCSOGOC.js.map +0 -1
  66. package/dist/chunk-NK2IP3RO.cjs +0 -191
  67. package/dist/chunk-NK2IP3RO.cjs.map +0 -1
  68. package/dist/chunk-WSYCRXET.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/customInstrumentation.ts","../src/bundler/index.ts"],"names":["rollup","esbuild","commonjs","MastraBundler","emptyDir","ensureDir","join","dirname","fileURLToPath","copy","writeFile","createBundler","analyzeBundle","DepsService","stat","getInputOptions","existsSync","virtual","globby","path","fsExtra","FileService","getBundlerOptions","error","MastraError","ErrorDomain","ErrorCategory","writeTelemetryConfig","getPackageRootPath","readJSON","collectTransitiveWorkspaceDependencies","packWorkspaceDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,+BAAA,CACd,WACA,MAAA,EAGA;AACA,EAAA,OAAOA,aAAA,CAAO;AAAA,IACZ,QAAA,EAAU,QAAA;AAAA,IACV,KAAA,EAAO;AAAA,MACL,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,SAAA,EAAW,KAAA;AAAA,IACX,OAAA,EAAS;AAAA;AAAA,MAEPC,yBAAA,EAAQ;AAAA,MACRC,yBAAA,CAAS;AAAA,QACP,UAAA,EAAY,CAAC,KAAA,EAAO,KAAK,CAAA;AAAA,QACzB,cAAA,EAAgB,QAAA;AAAA,QAChB,uBAAA,EAAyB,IAAA;AAAA,QACzB,cAAA,EAAgB;AAAA,OACjB;AAAA;AACH,GACD,CAAA;AACH;AAEA,eAAsB,0BAAA,CACpB,SAAA,EACA,SAAA,EACA,OAAA,GAEI,EAAC,EAIJ;AACD,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,eAAA,EAAiB;AAAA,GACnB;AAEA,EAAA,MAAM,MAAA,GAAS,MAAM,+BAAA,CAAgC,SAAiB,CAAA;AAEtE,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,MAAM,OAAO,KAAA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AM,iBAAA,GAAoB,MAAM,IAAA,CAAK,oBAAA,CAAqB,UAAU,CAAA;AACpE,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,CAAE,MAAA;AACnD,IAAA,IAAI,cAAc,CAAA,EAAG;AACnB,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA,MAAA,EAAS,WAAW,IAAI,WAAA,KAAgB,CAAA,GAAI,MAAA,GAAS,OAAO,CAAA,CAAE,CAAA;AAAA,IACjF;AAAA,EACF;AACF","file":"chunk-OBHT43LS.cjs","sourcesContent":["import { rollup } from 'rollup';\nimport { esbuild } from './plugins/esbuild';\nimport commonjs from '@rollup/plugin-commonjs';\n\nexport function getCustomInstrumentationBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n instrumentation: entryFile,\n },\n treeshake: false,\n plugins: [\n // transpile typescript to something we understand\n esbuild(),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n ],\n });\n}\n\nexport async function writeCustomInstrumentation(\n entryFile: string,\n outputDir: string,\n options: {\n sourcemap?: boolean;\n } = {},\n): Promise<{\n hasCustomConfig: boolean;\n externalDependencies: string[];\n}> {\n const result = {\n hasCustomConfig: false,\n } as const;\n\n const bundle = await getCustomInstrumentationBundler(entryFile, result);\n\n const { output } = await bundle.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n sourcemap: options.sourcemap,\n });\n const externals = output[0].imports.filter(x => !x.startsWith('./'));\n\n return { ...result, externalDependencies: externals };\n}\n","import { existsSync } from 'node:fs';\nimport { stat, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { MastraBundler } from '@mastra/core/bundler';\nimport { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport virtual from '@rollup/plugin-virtual';\nimport fsExtra, { copy, ensureDir, readJSON, emptyDir } from 'fs-extra/esm';\nimport { globby } from 'globby';\nimport type { InputOptions, OutputOptions } from 'rollup';\nimport { analyzeBundle } from '../build/analyze';\nimport { createBundler as createBundlerUtil, getInputOptions } from '../build/bundler';\nimport { getBundlerOptions } from '../build/bundlerOptions';\nimport { writeCustomInstrumentation } from '../build/customInstrumentation';\nimport { writeTelemetryConfig } from '../build/telemetry';\nimport { getPackageRootPath } from '../build/utils';\nimport { DepsService } from '../services/deps';\nimport { FileService } from '../services/fs';\nimport { collectTransitiveWorkspaceDependencies, packWorkspaceDependencies } from './workspaceDependencies';\n\nexport abstract class Bundler extends MastraBundler {\n protected analyzeOutputDir = '.build';\n protected outputDir = 'output';\n\n constructor(name: string, component: 'BUNDLER' | 'DEPLOYER' = 'BUNDLER') {\n super({ name, component });\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n // Clean up the output directory first\n await emptyDir(outputDirectory);\n\n await ensureDir(join(outputDirectory, this.analyzeOutputDir));\n await ensureDir(join(outputDirectory, this.outputDir));\n }\n\n async writeInstrumentationFile(outputDirectory: string, customInstrumentationFile?: string) {\n const instrumentationFile = join(outputDirectory, 'instrumentation.mjs');\n const __dirname = dirname(fileURLToPath(import.meta.url));\n\n if (customInstrumentationFile) {\n await copy(customInstrumentationFile, instrumentationFile);\n } else {\n await copy(join(__dirname, 'templates', 'instrumentation-template.js'), instrumentationFile);\n }\n }\n\n async writePackageJson(\n outputDirectory: string,\n dependencies: Map<string, string>,\n resolutions?: Record<string, string>,\n ) {\n this.logger.debug(`Writing project's package.json`);\n\n await ensureDir(outputDirectory);\n const pkgPath = join(outputDirectory, 'package.json');\n\n const dependenciesMap = new Map();\n for (const [key, value] of dependencies.entries()) {\n if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, value);\n } else {\n // For non-scoped packages, take only the first part before any slash\n const pkgName = key.split('/')[0] || key;\n dependenciesMap.set(pkgName, value);\n }\n }\n\n // add telemetry dependencies\n dependenciesMap.set('@opentelemetry/core', '^2.0.1');\n dependenciesMap.set('@opentelemetry/auto-instrumentations-node', '^0.59.0');\n dependenciesMap.set('@opentelemetry/exporter-trace-otlp-grpc', '^0.201.0');\n dependenciesMap.set('@opentelemetry/exporter-trace-otlp-http', '^0.201.0');\n dependenciesMap.set('@opentelemetry/resources', '^2.0.1');\n dependenciesMap.set('@opentelemetry/sdk-node', '^0.201.0');\n dependenciesMap.set('@opentelemetry/sdk-trace-base', '^2.0.1');\n dependenciesMap.set('@opentelemetry/semantic-conventions', '^1.33.0');\n dependenciesMap.set('@opentelemetry/instrumentation', '^0.202.0');\n\n await writeFile(\n pkgPath,\n JSON.stringify(\n {\n name: 'server',\n version: '1.0.0',\n description: '',\n type: 'module',\n main: 'index.mjs',\n scripts: {\n start: 'node --import=./instrumentation.mjs --import=@opentelemetry/instrumentation/hook.mjs ./index.mjs',\n },\n author: 'Mastra',\n license: 'ISC',\n dependencies: Object.fromEntries(dependenciesMap.entries()),\n ...(Object.keys(resolutions ?? {}).length > 0 && { resolutions }),\n pnpm: {\n neverBuiltDependencies: [],\n },\n },\n null,\n 2,\n ),\n );\n }\n\n protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & { dir: string }) {\n return createBundlerUtil(inputOptions, outputOptions);\n }\n\n protected async analyze(entry: string | string[], mastraFile: string, outputDirectory: string) {\n return await analyzeBundle(\n ([] as string[]).concat(entry),\n mastraFile,\n join(outputDirectory, this.analyzeOutputDir),\n 'node',\n this.logger,\n );\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n }\n\n protected async copyPublic(mastraDir: string, outputDirectory: string) {\n const publicDir = join(mastraDir, 'public');\n\n try {\n await stat(publicDir);\n } catch {\n return;\n }\n\n await copy(publicDir, join(outputDirectory, this.outputDir));\n }\n\n protected async copyDOTNPMRC({\n rootDir = process.cwd(),\n outputDirectory,\n }: {\n rootDir?: string;\n outputDirectory: string;\n }) {\n const sourceDotNpmRcPath = join(rootDir, '.npmrc');\n const targetDotNpmRcPath = join(outputDirectory, this.outputDir, '.npmrc');\n\n try {\n await stat(sourceDotNpmRcPath);\n await copy(sourceDotNpmRcPath, targetDotNpmRcPath);\n } catch {\n return;\n }\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n { enableSourcemap = false, enableEsmShim = true }: { enableSourcemap?: boolean; enableEsmShim?: boolean } = {},\n ) {\n const inputOptions: InputOptions = await getInputOptions(\n mastraEntryFile,\n analyzedBundleInfo,\n 'node',\n {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n },\n { sourcemap: enableSourcemap, enableEsmShim },\n );\n const isVirtual = serverFile.includes('\\n') || existsSync(serverFile);\n\n const toolsInputOptions = await this.getToolsInputOptions(toolsPaths);\n\n if (isVirtual) {\n inputOptions.input = { index: '#entry', ...toolsInputOptions };\n\n if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.unshift(virtual({ '#entry': serverFile }));\n } else {\n inputOptions.plugins = [virtual({ '#entry': serverFile })];\n }\n } else {\n inputOptions.input = { index: serverFile, ...toolsInputOptions };\n }\n\n return inputOptions;\n }\n\n async getToolsInputOptions(toolsPaths: (string | string[])[]) {\n const inputs: Record<string, string> = {};\n\n for (const toolPath of toolsPaths) {\n const expandedPaths = await globby(toolPath, {});\n\n for (const path of expandedPaths) {\n if (await fsExtra.pathExists(path)) {\n const fileService = new FileService();\n const entryFile = fileService.getFirstExistingFile([\n join(path, 'index.ts'),\n join(path, 'index.js'),\n path, // if path itself is a file\n ]);\n\n // if it doesn't exist or is a dir skip it. using a dir as a tool will crash the process\n if (!entryFile || (await stat(entryFile)).isDirectory()) {\n this.logger.warn(`No entry file found in ${path}, skipping...`);\n continue;\n }\n\n const uniqueToolID = crypto.randomUUID();\n inputs[`tools/${uniqueToolID}`] = entryFile;\n } else {\n this.logger.warn(`Tool path ${path} does not exist, skipping...`);\n }\n }\n }\n\n return inputs;\n }\n\n protected async _bundle(\n serverFile: string,\n mastraEntryFile: string,\n outputDirectory: string,\n toolsPaths: (string | string[])[] = [],\n bundleLocation: string = join(outputDirectory, this.outputDir),\n ): Promise<void> {\n this.logger.info('Start bundling Mastra');\n\n let sourcemap = false;\n\n try {\n const bundlerOptions = await getBundlerOptions(mastraEntryFile, outputDirectory);\n sourcemap = !!bundlerOptions?.sourcemap;\n } catch (error) {\n this.logger.debug('Failed to get bundler options, sourcemap will be disabled', { error });\n }\n\n let analyzedBundleInfo;\n try {\n const resolvedToolsPaths = await this.getToolsInputOptions(toolsPaths);\n analyzedBundleInfo = await analyzeBundle(\n [serverFile, ...Object.values(resolvedToolsPaths)],\n mastraEntryFile,\n join(outputDirectory, this.analyzeOutputDir),\n 'node',\n this.logger,\n sourcemap,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_ANALYZE_FAILED',\n text: `Failed to analyze Mastra application: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n\n let externalDependencies: string[];\n try {\n const result = await writeTelemetryConfig(mastraEntryFile, join(outputDirectory, this.outputDir));\n\n externalDependencies = result?.externalDependencies ?? [];\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_TELEMETRY_FAILED',\n text: `Failed to write telemetry config: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n\n const mastraFolder = dirname(mastraEntryFile);\n\n const fileService = new FileService();\n const customInstrumentation = fileService.getFirstExistingFileOrUndefined([\n join(mastraFolder, 'instrumentation.js'),\n join(mastraFolder, 'instrumentation.ts'),\n join(mastraFolder, 'instrumentation.mjs'),\n ]);\n\n try {\n if (customInstrumentation) {\n const result = await writeCustomInstrumentation(customInstrumentation, join(outputDirectory, this.outputDir), {\n sourcemap,\n });\n externalDependencies = [...externalDependencies, ...result.externalDependencies];\n await this.writeInstrumentationFile(join(outputDirectory, this.outputDir), customInstrumentation);\n } else {\n await this.writeInstrumentationFile(join(outputDirectory, this.outputDir));\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_INSTRUMENTATION_FILE_FAILED',\n text: `Failed to write instrumentation file: ${message}, ${customInstrumentation ? ` Found custom instrumentation file: ${customInstrumentation}` : ''}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n\n const dependenciesToInstall = new Map<string, string>();\n\n // Add extenal dependencies from telemetry file\n for (const external of externalDependencies) {\n dependenciesToInstall.set(external, 'latest');\n }\n\n const workspaceDependencies = new Set<string>();\n for (const dep of analyzedBundleInfo.externalDependencies) {\n try {\n if (analyzedBundleInfo.workspaceMap.has(dep)) {\n workspaceDependencies.add(dep);\n continue;\n }\n\n const rootPath = await getPackageRootPath(dep);\n const pkg = await readJSON(`${rootPath}/package.json`);\n\n dependenciesToInstall.set(dep, pkg.version);\n } catch {\n dependenciesToInstall.set(dep, 'latest');\n }\n }\n\n let resolutions: Record<string, string> = {};\n if (workspaceDependencies.size > 0) {\n try {\n const result = collectTransitiveWorkspaceDependencies({\n workspaceMap: analyzedBundleInfo.workspaceMap,\n initialDependencies: workspaceDependencies,\n logger: this.logger,\n });\n resolutions = result.resolutions;\n\n // Update dependenciesToInstall with the resolved TGZ paths\n Object.entries(resolutions).forEach(([pkgName, tgzPath]) => {\n dependenciesToInstall.set(pkgName, tgzPath);\n });\n\n await packWorkspaceDependencies({\n workspaceMap: analyzedBundleInfo.workspaceMap,\n usedWorkspacePackages: result.usedWorkspacePackages,\n bundleOutputDir: join(outputDirectory, this.outputDir),\n logger: this.logger,\n });\n } catch (error) {\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_WORKSPACE_DEPS_FAILED',\n text: `Failed to collect and pack workspace dependencies.`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.USER,\n },\n error,\n );\n }\n }\n\n try {\n await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall, resolutions);\n\n this.logger.info('Bundling Mastra application');\n const inputOptions: InputOptions = await this.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n { enableSourcemap: sourcemap },\n );\n\n const bundler = await this.createBundler(\n {\n ...inputOptions,\n logLevel: inputOptions.logLevel === 'silent' ? 'warn' : inputOptions.logLevel,\n onwarn: warning => {\n if (warning.code === 'CIRCULAR_DEPENDENCY') {\n if (warning.ids?.[0]?.includes('node_modules')) {\n return;\n }\n\n this.logger.warn(`Circular dependency found:\n\\t${warning.message.replace('Circular dependency: ', '')}`);\n }\n },\n },\n {\n dir: bundleLocation,\n manualChunks: {\n mastra: ['#mastra'],\n },\n sourcemap,\n },\n );\n\n await bundler.write();\n const toolImports: string[] = [];\n const toolsExports: string[] = [];\n Array.from(Object.keys(inputOptions.input || {}))\n .filter(key => key.startsWith('tools/'))\n .forEach((key, index) => {\n const toolExport = `tool${index}`;\n toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);\n toolsExports.push(toolExport);\n });\n\n await writeFile(\n join(bundleLocation, 'tools.mjs'),\n `${toolImports.join('\\n')}\n\nexport const tools = [${toolsExports.join(', ')}]`,\n );\n this.logger.info('Bundling Mastra done');\n\n this.logger.info('Copying public files');\n await this.copyPublic(dirname(mastraEntryFile), outputDirectory);\n this.logger.info('Done copying public files');\n\n this.logger.info('Copying .npmrc file');\n await this.copyDOTNPMRC({ outputDirectory });\n\n this.logger.info('Done copying .npmrc file');\n\n this.logger.info('Installing dependencies');\n await this.installDependencies(outputDirectory);\n\n this.logger.info('Done installing dependencies');\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED',\n text: `Failed during bundler bundle stage: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n }\n\n async lint(_entryFile: string, _outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const toolsInputOptions = await this.getToolsInputOptions(toolsPaths);\n const toolsLength = Object.keys(toolsInputOptions).length;\n if (toolsLength > 0) {\n this.logger.info(`Found ${toolsLength} ${toolsLength === 1 ? 'tool' : 'tools'}`);\n }\n }\n}\n"]}
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkKVBYKVQQ_cjs = require('./chunk-KVBYKVQQ.cjs');
3
+ var chunkT4L3WY7M_cjs = require('./chunk-T4L3WY7M.cjs');
4
4
 
5
5
  // src/build/babel/remove-all-options-telemetry.ts
6
6
  function removeAllOptionsExceptTelemetry(result, logger) {
7
- return chunkKVBYKVQQ_cjs.removeAllOptionsFromMastraExcept(result, "telemetry", logger);
7
+ return chunkT4L3WY7M_cjs.removeAllOptionsFromMastraExcept(result, "telemetry", logger);
8
8
  }
9
9
 
10
10
  // src/build/telemetry.ts
11
11
  async function writeTelemetryConfig(entryFile, outputDir, logger) {
12
- const result = await chunkKVBYKVQQ_cjs.extractMastraOption(
12
+ const result = await chunkT4L3WY7M_cjs.extractMastraOption(
13
13
  "telemetry",
14
14
  entryFile,
15
15
  removeAllOptionsExceptTelemetry,
@@ -24,5 +24,5 @@ async function writeTelemetryConfig(entryFile, outputDir, logger) {
24
24
  }
25
25
 
26
26
  exports.writeTelemetryConfig = writeTelemetryConfig;
27
- //# sourceMappingURL=chunk-WHMSFLP7.cjs.map
28
- //# sourceMappingURL=chunk-WHMSFLP7.cjs.map
27
+ //# sourceMappingURL=chunk-PX6ZHD5K.cjs.map
28
+ //# sourceMappingURL=chunk-PX6ZHD5K.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/build/babel/remove-all-options-telemetry.ts","../src/build/telemetry.ts"],"names":["removeAllOptionsFromMastraExcept","extractMastraOption"],"mappings":";;;;;AAGO,SAAS,+BAAA,CAAgC,QAAsC,MAAA,EAAwB;AAC5G,EAAA,OAAOA,kDAAA,CAAiC,MAAA,EAAQ,WAAA,EAAa,MAAM,CAAA;AACrE;;;ACSA,eAAsB,oBAAA,CACpB,SAAA,EACA,SAAA,EACA,MAAA,EACoD;AACpD,EAAA,MAAM,SAAS,MAAMC,qCAAA;AAAA,IACnB,WAAA;AAAA,IACA,SAAA;AAAA,IACA,+BAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,YAAA,CAAa,MAAA,CAAO,CAAC,CAAA,CAAE,OAAA,CAAQ,MAAA,CAAO,CAAA,CAAA,KAAK,CAAC,CAAA,CAAE,UAAA,CAAW,IAAI,CAAC,CAAA;AAEvF,EAAA,OAAO,EAAE,sBAAsB,SAAA,EAAU;AAC3C","file":"chunk-WHMSFLP7.cjs","sourcesContent":["import { removeAllOptionsFromMastraExcept } from './remove-all-options-except';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function removeAllOptionsExceptTelemetry(result: { hasCustomConfig: boolean }, logger?: IMastraLogger) {\n return removeAllOptionsFromMastraExcept(result, 'telemetry', logger);\n}\n","import { removeAllOptionsExceptTelemetry } from './babel/remove-all-options-telemetry';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function getTelemetryBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('telemetry', entryFile, removeAllOptionsExceptTelemetry, result);\n}\n\nexport async function writeTelemetryConfig(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{ externalDependencies: string[] } | null> {\n const result = await extractMastraOption<Config['telemetry']>(\n 'telemetry',\n entryFile,\n removeAllOptionsExceptTelemetry,\n outputDir,\n logger,\n );\n\n if (!result) {\n return null;\n }\n\n const externals = result.bundleOutput.output[0].imports.filter(x => !x.startsWith('./'));\n\n return { externalDependencies: externals };\n}\n"]}
1
+ {"version":3,"sources":["../src/build/babel/remove-all-options-telemetry.ts","../src/build/telemetry.ts"],"names":["removeAllOptionsFromMastraExcept","extractMastraOption"],"mappings":";;;;;AAGO,SAAS,+BAAA,CAAgC,QAAsC,MAAA,EAAwB;AAC5G,EAAA,OAAOA,kDAAA,CAAiC,MAAA,EAAQ,WAAA,EAAa,MAAM,CAAA;AACrE;;;ACSA,eAAsB,oBAAA,CACpB,SAAA,EACA,SAAA,EACA,MAAA,EACoD;AACpD,EAAA,MAAM,SAAS,MAAMC,qCAAA;AAAA,IACnB,WAAA;AAAA,IACA,SAAA;AAAA,IACA,+BAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,YAAA,CAAa,MAAA,CAAO,CAAC,CAAA,CAAE,OAAA,CAAQ,MAAA,CAAO,CAAA,CAAA,KAAK,CAAC,CAAA,CAAE,UAAA,CAAW,IAAI,CAAC,CAAA;AAEvF,EAAA,OAAO,EAAE,sBAAsB,SAAA,EAAU;AAC3C","file":"chunk-PX6ZHD5K.cjs","sourcesContent":["import { removeAllOptionsFromMastraExcept } from './remove-all-options-except';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function removeAllOptionsExceptTelemetry(result: { hasCustomConfig: boolean }, logger?: IMastraLogger) {\n return removeAllOptionsFromMastraExcept(result, 'telemetry', logger);\n}\n","import { removeAllOptionsExceptTelemetry } from './babel/remove-all-options-telemetry';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function getTelemetryBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('telemetry', entryFile, removeAllOptionsExceptTelemetry, result);\n}\n\nexport async function writeTelemetryConfig(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{ externalDependencies: string[] } | null> {\n const result = await extractMastraOption<Config['telemetry']>(\n 'telemetry',\n entryFile,\n removeAllOptionsExceptTelemetry,\n outputDir,\n logger,\n );\n\n if (!result) {\n return null;\n }\n\n const externals = result.bundleOutput.output[0].imports.filter(x => !x.startsWith('./'));\n\n return { externalDependencies: externals };\n}\n"]}
@@ -1,19 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunkNK2IP3RO_cjs = require('./chunk-NK2IP3RO.cjs');
4
- var chunkAM2S5WCK_cjs = require('./chunk-AM2S5WCK.cjs');
3
+ var chunkHR2HOA5D_cjs = require('./chunk-HR2HOA5D.cjs');
5
4
  var babel = require('@babel/core');
6
5
  var commonjs2 = require('@rollup/plugin-commonjs');
7
6
  var json2 = require('@rollup/plugin-json');
8
7
  var nodeResolve = require('@rollup/plugin-node-resolve');
9
8
  var virtual = require('@rollup/plugin-virtual');
9
+ var esmShim = require('@rollup/plugin-esm-shim');
10
10
  var fs = require('fs');
11
11
  var promises = require('fs/promises');
12
12
  var url = require('url');
13
13
  var rollup = require('rollup');
14
+ var originalEsbuild = require('rollup-plugin-esbuild');
14
15
  var module$1 = require('module');
15
16
  var path = require('path');
16
17
  var child_process = require('child_process');
18
+ var typescriptPaths = require('typescript-paths');
17
19
  var rollupPlugin = require('@optimize-lodash/rollup-plugin');
18
20
  var localPkg = require('local-pkg');
19
21
  var slugify = require('@sindresorhus/slugify');
@@ -45,8 +47,20 @@ var commonjs2__default = /*#__PURE__*/_interopDefault(commonjs2);
45
47
  var json2__default = /*#__PURE__*/_interopDefault(json2);
46
48
  var nodeResolve__default = /*#__PURE__*/_interopDefault(nodeResolve);
47
49
  var virtual__default = /*#__PURE__*/_interopDefault(virtual);
50
+ var esmShim__default = /*#__PURE__*/_interopDefault(esmShim);
51
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
52
+ var originalEsbuild__default = /*#__PURE__*/_interopDefault(originalEsbuild);
53
+ var path__default = /*#__PURE__*/_interopDefault(path);
48
54
  var slugify__default = /*#__PURE__*/_interopDefault(slugify);
49
55
 
56
+ function esbuild(options = {}) {
57
+ return originalEsbuild__default.default({
58
+ target: "node20",
59
+ platform: "node",
60
+ minify: false,
61
+ ...options
62
+ });
63
+ }
50
64
  function isNodeBuiltin(dep) {
51
65
  const [pkg] = dep.split("/");
52
66
  return dep.startsWith("node:") || module$1.builtinModules.includes(dep) || module$1.builtinModules.includes(pkg);
@@ -58,8 +72,81 @@ function aliasHono() {
58
72
  if (!id.startsWith("@hono/") && !id.startsWith("hono/") && id !== "hono" && id !== "hono-openapi") {
59
73
  return;
60
74
  }
61
- const path = undefined(id);
62
- return url.fileURLToPath(path);
75
+ const path2 = undefined(id);
76
+ return url.fileURLToPath(path2);
77
+ }
78
+ };
79
+ }
80
+ function removeDeployer() {
81
+ const t = babel__namespace.default.types;
82
+ return {
83
+ name: "remove-deployer",
84
+ visitor: {
85
+ NewExpression(path2, state) {
86
+ const varDeclaratorPath = path2.findParent((path3) => t.isVariableDeclarator(path3.node));
87
+ if (!varDeclaratorPath) {
88
+ return;
89
+ }
90
+ const parentNode = path2.parentPath.node;
91
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
92
+ return;
93
+ }
94
+ if (!state.hasReplaced) {
95
+ state.hasReplaced = true;
96
+ const newMastraObj = t.cloneNode(path2.node);
97
+ if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {
98
+ const deployer = newMastraObj.arguments[0].properties.find(
99
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
100
+ );
101
+ if (!deployer) {
102
+ return;
103
+ }
104
+ newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(
105
+ (prop) => prop !== deployer
106
+ );
107
+ if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {
108
+ const deployerBinding = state.file.scope.getBinding(deployer.value.name);
109
+ if (deployerBinding) {
110
+ deployerBinding?.path?.parentPath?.remove();
111
+ }
112
+ }
113
+ path2.replaceWith(newMastraObj);
114
+ }
115
+ }
116
+ }
117
+ }
118
+ };
119
+ }
120
+
121
+ // src/build/plugins/remove-deployer.ts
122
+ function removeDeployer2(mastraEntry, options) {
123
+ return {
124
+ name: "remove-deployer",
125
+ transform(code, id) {
126
+ if (id !== mastraEntry) {
127
+ return;
128
+ }
129
+ return new Promise((resolve, reject) => {
130
+ babel__namespace.transform(
131
+ code,
132
+ {
133
+ babelrc: false,
134
+ configFile: false,
135
+ filename: id,
136
+ plugins: [removeDeployer],
137
+ sourceMaps: options?.sourcemap
138
+ },
139
+ (err, result) => {
140
+ if (err) {
141
+ return reject(err);
142
+ }
143
+ resolve({
144
+ code: result.code,
145
+ map: result.map
146
+ });
147
+ }
148
+ );
149
+ });
63
150
  }
64
151
  };
65
152
  }
@@ -100,6 +187,76 @@ function validate(file) {
100
187
  }
101
188
  );
102
189
  }
190
+ var PLUGIN_NAME = "tsconfig-paths";
191
+ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
192
+ let handler;
193
+ return {
194
+ name: PLUGIN_NAME,
195
+ buildStart() {
196
+ handler = typescriptPaths.createHandler({
197
+ log: () => {
198
+ },
199
+ tsConfigPath,
200
+ respectCoreModule,
201
+ falllback: (moduleName) => fs__default.default.existsSync(moduleName)
202
+ });
203
+ return;
204
+ },
205
+ async resolveId(request, importer, options) {
206
+ if (!importer || request.startsWith("\0")) {
207
+ return null;
208
+ }
209
+ const moduleName = handler?.(request, path.normalize(importer));
210
+ if (!moduleName) {
211
+ let importerMeta = {};
212
+ const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });
213
+ if (!resolved) {
214
+ return null;
215
+ }
216
+ if (localResolve) {
217
+ const importerInfo = this.getModuleInfo(importer);
218
+ importerMeta = importerInfo?.meta || {};
219
+ if (!request.startsWith("./") && !request.startsWith("../") && importerMeta?.[PLUGIN_NAME]?.resolved) {
220
+ return {
221
+ ...resolved,
222
+ external: !request.startsWith("hono/") && request !== "hono"
223
+ };
224
+ }
225
+ }
226
+ return {
227
+ ...resolved,
228
+ meta: {
229
+ ...resolved.meta || {},
230
+ ...importerMeta
231
+ }
232
+ };
233
+ }
234
+ if (!path__default.default.extname(moduleName)) {
235
+ const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
236
+ if (!resolved) {
237
+ return null;
238
+ }
239
+ return {
240
+ ...resolved,
241
+ meta: {
242
+ ...resolved.meta,
243
+ [PLUGIN_NAME]: {
244
+ resolved: true
245
+ }
246
+ }
247
+ };
248
+ }
249
+ return {
250
+ id: moduleName,
251
+ meta: {
252
+ [PLUGIN_NAME]: {
253
+ resolved: true
254
+ }
255
+ }
256
+ };
257
+ }
258
+ };
259
+ }
103
260
  function removeAllOptionsFromMastraExcept(result, option, logger) {
104
261
  const t = babel__namespace.default.types;
105
262
  return {
@@ -107,29 +264,29 @@ function removeAllOptionsFromMastraExcept(result, option, logger) {
107
264
  visitor: {
108
265
  ExportNamedDeclaration: {
109
266
  // remove all exports
110
- exit(path) {
111
- path.remove();
267
+ exit(path2) {
268
+ path2.remove();
112
269
  }
113
270
  },
114
- NewExpression(path, state) {
115
- const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
271
+ NewExpression(path2, state) {
272
+ const varDeclaratorPath = path2.findParent((path3) => t.isVariableDeclarator(path3.node));
116
273
  if (!varDeclaratorPath) {
117
274
  return;
118
275
  }
119
- const parentNode = path.parentPath.node;
276
+ const parentNode = path2.parentPath.node;
120
277
  if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
121
278
  return;
122
279
  }
123
280
  let mastraArgs = t.objectExpression([]);
124
- if (t.isObjectExpression(path.node.arguments[0])) {
125
- mastraArgs = path.node.arguments[0];
281
+ if (t.isObjectExpression(path2.node.arguments[0])) {
282
+ mastraArgs = path2.node.arguments[0];
126
283
  }
127
284
  let telemetry = mastraArgs.properties.find(
128
285
  // @ts-ignore
129
286
  (prop) => prop.key.name === option
130
287
  );
131
288
  let telemetryValue = t.objectExpression([]);
132
- const programPath = path.scope.getProgramParent().path;
289
+ const programPath = path2.scope.getProgramParent().path;
133
290
  if (!programPath) {
134
291
  return;
135
292
  }
@@ -139,7 +296,7 @@ function removeAllOptionsFromMastraExcept(result, option, logger) {
139
296
  if (t.isIdentifier(telemetry.value) && telemetry.value.name === option) {
140
297
  const telemetryBinding = state.file.scope.getBinding(option);
141
298
  if (telemetryBinding && t.isVariableDeclarator(telemetryBinding.path.node)) {
142
- const id = path.scope.generateUidIdentifier(option);
299
+ const id = path2.scope.generateUidIdentifier(option);
143
300
  telemetryBinding.path.replaceWith(t.variableDeclarator(id, telemetryBinding.path.node.init));
144
301
  telemetryValue = id;
145
302
  }
@@ -152,8 +309,8 @@ function removeAllOptionsFromMastraExcept(result, option, logger) {
152
309
  programPath.node.body.push(exportDeclaration);
153
310
  },
154
311
  Program: {
155
- exit(path) {
156
- const hasExport = path.node.body.some(
312
+ exit(path2) {
313
+ const hasExport = path2.node.body.some(
157
314
  (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
158
315
  );
159
316
  if (!hasExport) {
@@ -169,7 +326,7 @@ export const mastra = new Mastra({
169
326
  t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
170
327
  []
171
328
  );
172
- path.node.body.push(fallbackExportDeclaration);
329
+ path2.node.body.push(fallbackExportDeclaration);
173
330
  }
174
331
  }
175
332
  }
@@ -186,9 +343,9 @@ function removeNonReferencedNodes() {
186
343
  return {
187
344
  name: "remove-non-referenced-nodes",
188
345
  visitor: {
189
- Program(path) {
190
- const scope = path.scope;
191
- const currentBody = path.get("body");
346
+ Program(path2) {
347
+ const scope = path2.scope;
348
+ const currentBody = path2.get("body");
192
349
  const filteredBody = currentBody.filter((childPath) => {
193
350
  if (childPath.isExportDeclaration()) {
194
351
  return true;
@@ -220,7 +377,7 @@ function removeNonReferencedNodes() {
220
377
  }
221
378
  return false;
222
379
  });
223
- path.set(
380
+ path2.set(
224
381
  "body",
225
382
  filteredBody.map((p) => p.node)
226
383
  );
@@ -262,9 +419,9 @@ function extractMastraOptionBundler(name, entryFile, transformer, result, logger
262
419
  },
263
420
  treeshake: "smallest",
264
421
  plugins: [
265
- chunkNK2IP3RO_cjs.tsConfigPaths(),
422
+ tsConfigPaths(),
266
423
  // transpile typescript to something we understand
267
- chunkNK2IP3RO_cjs.esbuild(),
424
+ esbuild(),
268
425
  rollupPlugin.optimizeLodashImports(),
269
426
  commonjs2__default.default({
270
427
  extensions: [".js", ".ts"],
@@ -302,7 +459,7 @@ function extractMastraOptionBundler(name, entryFile, transformer, result, logger
302
459
  }
303
460
  },
304
461
  // let esbuild remove all unused imports
305
- chunkNK2IP3RO_cjs.esbuild(),
462
+ esbuild(),
306
463
  {
307
464
  name: "cleanup",
308
465
  transform(code, id) {
@@ -313,7 +470,7 @@ function extractMastraOptionBundler(name, entryFile, transformer, result, logger
313
470
  }
314
471
  },
315
472
  // let esbuild remove it once more
316
- chunkNK2IP3RO_cjs.esbuild()
473
+ esbuild()
317
474
  ]
318
475
  });
319
476
  }
@@ -356,16 +513,16 @@ function checkConfigExport(result) {
356
513
  const mastraVars = /* @__PURE__ */ new Set();
357
514
  return {
358
515
  visitor: {
359
- ExportNamedDeclaration(path) {
360
- const decl = path.node.declaration;
516
+ ExportNamedDeclaration(path2) {
517
+ const decl = path2.node.declaration;
361
518
  if (t.isVariableDeclaration(decl)) {
362
519
  const varDecl = decl.declarations[0];
363
520
  if (t.isIdentifier(varDecl?.id, { name: "mastra" }) && t.isNewExpression(varDecl.init) && t.isIdentifier(varDecl.init.callee, { name: "Mastra" })) {
364
521
  result.hasValidConfig = true;
365
522
  }
366
523
  }
367
- if (Array.isArray(path.node.specifiers)) {
368
- for (const spec of path.node.specifiers) {
524
+ if (Array.isArray(path2.node.specifiers)) {
525
+ for (const spec of path2.node.specifiers) {
369
526
  if (t.isExportSpecifier(spec) && t.isIdentifier(spec.exported, { name: "mastra" }) && t.isIdentifier(spec.local) && mastraVars.has(spec.local.name)) {
370
527
  result.hasValidConfig = true;
371
528
  }
@@ -373,8 +530,8 @@ function checkConfigExport(result) {
373
530
  }
374
531
  },
375
532
  // For cases 2-4 we need to track whether those variables are assigned to `new Mastra()`
376
- VariableDeclaration(path) {
377
- for (const decl of path.node.declarations) {
533
+ VariableDeclaration(path2) {
534
+ for (const decl of path2.node.declarations) {
378
535
  if (t.isIdentifier(decl.id) && t.isNewExpression(decl.init) && t.isIdentifier(decl.init.callee, { name: "Mastra" })) {
379
536
  mastraVars.add(decl.id.name);
380
537
  }
@@ -400,6 +557,9 @@ async function getPackageRootPath(packageName) {
400
557
  }
401
558
  return rootPath;
402
559
  }
560
+ function getCompiledDepCachePath(rootPath, packageName) {
561
+ return path.join(rootPath, "node_modules", ".cache", packageName);
562
+ }
403
563
  var createWorkspacePackageMap = async () => {
404
564
  const workspaces = await findWorkspaces.findWorkspaces();
405
565
  const workspaceMap = new Map(
@@ -435,7 +595,7 @@ var collectTransitiveWorkspaceDependencies = ({
435
595
  if (!root) {
436
596
  throw new Error("Could not find workspace root");
437
597
  }
438
- const depsService = new chunkAM2S5WCK_cjs.DepsService(root.location);
598
+ const depsService = new chunkHR2HOA5D_cjs.DepsService(root.location);
439
599
  depsService.__setLogger(logger);
440
600
  const sanitizedName = slugify__default.default(pkgName);
441
601
  const tgzPath = depsService.getWorkspaceDependencyPath({
@@ -463,7 +623,7 @@ var packWorkspaceDependencies = async ({
463
623
  if (!root) {
464
624
  throw new Error("Could not find workspace root");
465
625
  }
466
- const depsService = new chunkAM2S5WCK_cjs.DepsService(root.location);
626
+ const depsService = new chunkHR2HOA5D_cjs.DepsService(root.location);
467
627
  depsService.__setLogger(logger);
468
628
  if (usedWorkspacePackages.size > 0) {
469
629
  const workspaceDirPath = path.join(bundleOutputDir, "workspace-module");
@@ -479,8 +639,9 @@ var packWorkspaceDependencies = async ({
479
639
  await Promise.all(
480
640
  batch.map(async (pkgName) => {
481
641
  const dep = workspaceMap.get(pkgName);
642
+ const sanitizedName = slugify__default.default(pkgName);
482
643
  if (!dep) return;
483
- await depsService.pack({ dir: dep.location, destination: workspaceDirPath });
644
+ await depsService.pack({ dir: dep.location, destination: workspaceDirPath, sanitizedName });
484
645
  })
485
646
  );
486
647
  }
@@ -523,9 +684,6 @@ function findExternalImporter(module, external, allOutputs) {
523
684
  }
524
685
  return null;
525
686
  }
526
- function isRelativePath(id) {
527
- return id === "." || id === ".." || id.startsWith("./") || id.startsWith("../");
528
- }
529
687
  async function analyze(entry, mastraEntry, isVirtualFile, platform, logger, sourcemapEnabled = false, workspaceMap) {
530
688
  logger.info("Analyzing dependencies...");
531
689
  let virtualPlugin = null;
@@ -543,7 +701,7 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger, sour
543
701
  preserveSymlinks: true,
544
702
  plugins: [
545
703
  virtualPlugin,
546
- chunkNK2IP3RO_cjs.tsConfigPaths(),
704
+ tsConfigPaths(),
547
705
  {
548
706
  name: "custom-alias-resolver",
549
707
  resolveId(id) {
@@ -565,15 +723,15 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger, sour
565
723
  }
566
724
  },
567
725
  json2__default.default(),
568
- chunkNK2IP3RO_cjs.esbuild(),
726
+ esbuild(),
569
727
  commonjs2__default.default({
570
728
  strictRequires: "debug",
571
729
  ignoreTryCatch: false,
572
730
  transformMixedEsModules: true,
573
731
  extensions: [".js", ".ts"]
574
732
  }),
575
- chunkNK2IP3RO_cjs.removeDeployer(normalizedMastraEntry, { sourcemap: sourcemapEnabled }),
576
- chunkNK2IP3RO_cjs.esbuild()
733
+ removeDeployer2(normalizedMastraEntry, { sourcemap: sourcemapEnabled }),
734
+ esbuild()
577
735
  ].filter(Boolean)
578
736
  });
579
737
  const { output } = await optimizerBundler.generate({
@@ -610,17 +768,22 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger, sour
610
768
  }
611
769
  return depsToOptimize;
612
770
  }
613
- async function bundleExternals(depsToOptimize, outputDir, logger, options) {
771
+ async function bundleExternals(depsToOptimize, outputDir, logger, bundlerOptions, meta) {
614
772
  logger.info("Optimizing dependencies...");
615
773
  logger.debug(
616
774
  `${Array.from(depsToOptimize.keys()).map((key) => `- ${key}`).join("\n")}`
617
775
  );
618
- const { externals: customExternals = [], transpilePackages = [] } = options || {};
776
+ const { externals: customExternals = [], transpilePackages = [], isDev = false } = bundlerOptions || {};
777
+ const { workspaceRoot = null, workspaceMap = /* @__PURE__ */ new Map() } = meta || {};
619
778
  const allExternals = [...globalExternals, ...customExternals];
620
779
  const reverseVirtualReferenceMap = /* @__PURE__ */ new Map();
621
780
  const virtualDependencies = /* @__PURE__ */ new Map();
622
- for (const [dep, { exports }] of depsToOptimize.entries()) {
623
- const name = dep.replaceAll("/", "-");
781
+ for (const [dep, { exports, isWorkspace, rootPath }] of depsToOptimize.entries()) {
782
+ let name = dep.replaceAll("/", "-");
783
+ if (isWorkspace && rootPath && isDev && workspaceRoot) {
784
+ const absolutePath = getCompiledDepCachePath(rootPath, name);
785
+ name = absolutePath.replace(workspaceRoot, "").replace(/^[/\\]+/, "");
786
+ }
624
787
  reverseVirtualReferenceMap.set(name, dep);
625
788
  const virtualFile = [];
626
789
  let exportStringBuilder = [];
@@ -657,8 +820,6 @@ async function bundleExternals(depsToOptimize, outputDir, logger, options) {
657
820
  },
658
821
  {}
659
822
  ),
660
- // this dependency breaks the build, so we need to exclude it
661
- // TODO actually fix this so we don't need to exclude it
662
823
  external: allExternals,
663
824
  treeshake: "smallest",
664
825
  plugins: [
@@ -671,21 +832,7 @@ async function bundleExternals(depsToOptimize, outputDir, logger, options) {
671
832
  {}
672
833
  )
673
834
  ),
674
- options?.isDev ? {
675
- name: "external-resolver",
676
- async resolveId(id, importer, options2) {
677
- const pathsToTranspile = [...transpilePackagesMap.values()];
678
- if (importer && pathsToTranspile.some((p) => importer?.startsWith(p)) && !isRelativePath(id)) {
679
- const resolved = await this.resolve(id, importer, { skipSelf: true, ...options2 });
680
- return {
681
- ...resolved,
682
- external: true
683
- };
684
- }
685
- return null;
686
- }
687
- } : null,
688
- transpilePackagesMap.size ? chunkNK2IP3RO_cjs.esbuild({
835
+ transpilePackagesMap.size ? esbuild({
689
836
  format: "esm",
690
837
  include: [...transpilePackagesMap.values()].map((p) => {
691
838
  return new RegExp(`^${p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/(?!.*node_modules).*$`);
@@ -696,9 +843,12 @@ async function bundleExternals(depsToOptimize, outputDir, logger, options) {
696
843
  transformMixedEsModules: true,
697
844
  ignoreTryCatch: false
698
845
  }),
846
+ isDev ? esmShim__default.default() : void 0,
699
847
  nodeResolve__default.default({
700
848
  preferBuiltins: true,
701
- exportConditions: ["node"]
849
+ exportConditions: ["node"],
850
+ // Do not embed external dependencies into files that we write to `node_modules/.cache` (for the mastra dev + workspace use case)
851
+ ...workspaceMap.size > 0 && isDev ? { resolveOnly: Array.from(workspaceMap.keys()) } : {}
702
852
  }),
703
853
  // hono is imported from deployer, so we need to resolve from here instead of the project root
704
854
  aliasHono(),
@@ -707,7 +857,12 @@ async function bundleExternals(depsToOptimize, outputDir, logger, options) {
707
857
  });
708
858
  const { output } = await bundler.write({
709
859
  format: "esm",
710
- dir: outputDir,
860
+ /**
861
+ * If Mastra is used inside a monorepo, we need to find the workspace root so that Rollup can use it as base for the output dir. This should only happen during `mastra dev`.
862
+ *
863
+ * Otherwise, use outputDir as normal.
864
+ */
865
+ dir: isDev ? workspaceRoot ? workspaceRoot : outputDir : outputDir,
711
866
  entryFileNames: "[name].mjs",
712
867
  chunkFileNames: "[name].mjs",
713
868
  hoistTransitiveImports: false
@@ -844,11 +999,14 @@ exports.analyzeBundle = analyzeBundle;
844
999
  exports.bundleExternals = bundleExternals;
845
1000
  exports.collectTransitiveWorkspaceDependencies = collectTransitiveWorkspaceDependencies;
846
1001
  exports.createWorkspacePackageMap = createWorkspacePackageMap;
1002
+ exports.esbuild = esbuild;
847
1003
  exports.extractMastraOption = extractMastraOption;
848
1004
  exports.getBundlerOptions = getBundlerOptions;
849
1005
  exports.getPackageName = getPackageName;
850
1006
  exports.getPackageRootPath = getPackageRootPath;
851
1007
  exports.packWorkspaceDependencies = packWorkspaceDependencies;
852
1008
  exports.removeAllOptionsFromMastraExcept = removeAllOptionsFromMastraExcept;
853
- //# sourceMappingURL=chunk-KVBYKVQQ.cjs.map
854
- //# sourceMappingURL=chunk-KVBYKVQQ.cjs.map
1009
+ exports.removeDeployer = removeDeployer2;
1010
+ exports.tsConfigPaths = tsConfigPaths;
1011
+ //# sourceMappingURL=chunk-T4L3WY7M.cjs.map
1012
+ //# sourceMappingURL=chunk-T4L3WY7M.cjs.map