@mastra/deployer 1.0.0-beta.11 → 1.0.0-beta.13

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 (66) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/build/analyze/bundleExternals.d.ts +4 -5
  3. package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
  4. package/dist/build/analyze.cjs +2 -2
  5. package/dist/build/analyze.d.ts +2 -2
  6. package/dist/build/analyze.d.ts.map +1 -1
  7. package/dist/build/analyze.js +1 -1
  8. package/dist/build/bundler.cjs +3 -3
  9. package/dist/build/bundler.d.ts +2 -1
  10. package/dist/build/bundler.d.ts.map +1 -1
  11. package/dist/build/bundler.js +1 -1
  12. package/dist/build/index.cjs +12 -12
  13. package/dist/build/index.js +4 -4
  14. package/dist/build/plugins/node-modules-extension-resolver.d.ts +7 -0
  15. package/dist/build/plugins/node-modules-extension-resolver.d.ts.map +1 -1
  16. package/dist/build/utils.d.ts +6 -0
  17. package/dist/build/utils.d.ts.map +1 -1
  18. package/dist/build/watcher.d.ts.map +1 -1
  19. package/dist/bundler/index.cjs +2 -2
  20. package/dist/bundler/index.d.ts +5 -5
  21. package/dist/bundler/index.d.ts.map +1 -1
  22. package/dist/bundler/index.js +1 -1
  23. package/dist/chunk-24GY667C.cjs +123 -0
  24. package/dist/chunk-24GY667C.cjs.map +1 -0
  25. package/dist/{chunk-PK3AX3KO.cjs → chunk-3GOE3SL2.cjs} +27 -23
  26. package/dist/chunk-3GOE3SL2.cjs.map +1 -0
  27. package/dist/{chunk-NM6R77PX.js → chunk-HHA2Y3AS.js} +7 -3
  28. package/dist/chunk-HHA2Y3AS.js.map +1 -0
  29. package/dist/{chunk-EHZKDGGA.cjs → chunk-KCGBR2X6.cjs} +106 -54
  30. package/dist/chunk-KCGBR2X6.cjs.map +1 -0
  31. package/dist/chunk-LENVOSFH.cjs +261 -0
  32. package/dist/chunk-LENVOSFH.cjs.map +1 -0
  33. package/dist/chunk-R6O3XWXM.js +249 -0
  34. package/dist/chunk-R6O3XWXM.js.map +1 -0
  35. package/dist/{chunk-3KATYU33.js → chunk-RGUNHE4Y.js} +89 -37
  36. package/dist/chunk-RGUNHE4Y.js.map +1 -0
  37. package/dist/{chunk-HFP6WWM5.js → chunk-SRPOHKWH.js} +6 -76
  38. package/dist/chunk-SRPOHKWH.js.map +1 -0
  39. package/dist/{chunk-F2LCS2DV.cjs → chunk-VA2CSOKJ.cjs} +7 -2
  40. package/dist/chunk-VA2CSOKJ.cjs.map +1 -0
  41. package/dist/{chunk-5OGQ7IFB.js → chunk-XTXGU6QF.js} +19 -15
  42. package/dist/chunk-XTXGU6QF.js.map +1 -0
  43. package/dist/index.cjs +5 -5
  44. package/dist/index.js +2 -2
  45. package/dist/server/index.cjs +4 -4
  46. package/dist/server/index.cjs.map +1 -1
  47. package/dist/server/index.js +2 -2
  48. package/dist/server/index.js.map +1 -1
  49. package/dist/validator/custom-resolver.cjs +2 -2
  50. package/dist/validator/custom-resolver.js +1 -1
  51. package/package.json +4 -5
  52. package/dist/chunk-3KATYU33.js.map +0 -1
  53. package/dist/chunk-5OGQ7IFB.js.map +0 -1
  54. package/dist/chunk-EHZKDGGA.cjs.map +0 -1
  55. package/dist/chunk-F2LCS2DV.cjs.map +0 -1
  56. package/dist/chunk-HFP6WWM5.js.map +0 -1
  57. package/dist/chunk-NM6R77PX.js.map +0 -1
  58. package/dist/chunk-PK3AX3KO.cjs.map +0 -1
  59. package/dist/chunk-UG72ONP7.js +0 -147
  60. package/dist/chunk-UG72ONP7.js.map +0 -1
  61. package/dist/chunk-Z33LQHGJ.cjs +0 -196
  62. package/dist/chunk-Z33LQHGJ.cjs.map +0 -1
  63. package/dist/chunk-ZPUTJSEC.cjs +0 -157
  64. package/dist/chunk-ZPUTJSEC.cjs.map +0 -1
  65. package/dist/server/handlers/prompt.d.ts +0 -3
  66. package/dist/server/handlers/prompt.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bundler/index.ts"],"names":["MastraBundler","emptyDir","ensureDir","join","writeFile","createBundler","analyzeBundle","DepsService","stat","copy","getWorkspaceInformation","pkg","dirname","getInputOptions","existsSync","virtual","slash","posix","glob","path","fsExtra","FileService","getBundlerOptions","error","MastraError","ErrorDomain","ErrorCategory","getPackageRootPath","readJSON"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,IAAe,OAAA,GAAf,cAA+BA,qBAAA,CAAc;AAAA,EACxC,gBAAA,GAAmB,QAAA;AAAA,EACnB,SAAA,GAAY,QAAA;AAAA,EAEtB,WAAA,CAAY,IAAA,EAAc,SAAA,GAAoC,SAAA,EAAW;AACvE,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,SAAA,EAAW,CAAA;AAAA,EAC3B;AAAA,EAEA,MAAM,QAAQ,eAAA,EAAwC;AAEpD,IAAA,MAAMC,iBAAS,eAAe,CAAA;AAE9B,IAAA,MAAMC,iBAAA,CAAUC,SAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,gBAAgB,CAAC,CAAA;AAC5D,IAAA,MAAMD,iBAAA,CAAUC,SAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,SAAS,CAAC,CAAA;AAAA,EACvD;AAAA,EAEA,MAAM,gBAAA,CACJ,eAAA,EACA,YAAA,EACA,WAAA,EACA;AACA,IAAA,IAAA,CAAK,MAAA,CAAO,MAAM,CAAA,8BAAA,CAAgC,CAAA;AAElD,IAAA,MAAMD,kBAAU,eAAe,CAAA;AAC/B,IAAA,MAAM,OAAA,GAAUC,SAAA,CAAK,eAAA,EAAiB,cAAc,CAAA;AAEpD,IAAA,MAAM,eAAA,uBAAsB,GAAA,EAAI;AAChC,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,CAAA,IAAK,YAAA,CAAa,SAAQ,EAAG;AACjD,MAAA,IAAI,GAAA,CAAI,UAAA,CAAW,GAAG,CAAA,EAAG;AAEvB,QAA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,qBAAA,CAAsB,UAAU,CAAA;AACrE,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-3GOE3SL2.cjs","sourcesContent":["import { existsSync } from 'node:fs';\nimport { stat, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { MastraBundler } from '@mastra/core/bundler';\nimport { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport virtual from '@rollup/plugin-virtual';\nimport * as pkg from 'empathic/package';\nimport fsExtra, { copy, ensureDir, readJSON, emptyDir } from 'fs-extra/esm';\nimport type { InputOptions, OutputOptions } from 'rollup';\nimport { glob } from 'tinyglobby';\nimport { analyzeBundle } from '../build/analyze';\nimport { createBundler as createBundlerUtil, getInputOptions } from '../build/bundler';\nimport { getBundlerOptions } from '../build/bundlerOptions';\nimport { getPackageRootPath } from '../build/package-info';\nimport { slash } from '../build/utils';\nimport { DepsService } from '../services/deps';\nimport { FileService } from '../services/fs';\nimport { getWorkspaceInformation } 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 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 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 ./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 {\n outputDir: join(outputDirectory, this.analyzeOutputDir),\n projectRoot: outputDirectory,\n platform: 'node',\n },\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 {\n enableSourcemap = false,\n enableEsmShim = true,\n externalsPreset = false,\n }: { enableSourcemap?: boolean; enableEsmShim?: boolean; externalsPreset?: boolean } = {},\n ) {\n const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });\n const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });\n const projectRoot = closestPkgJson ? dirname(closestPkgJson) : process.cwd();\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, workspaceRoot, projectRoot, enableEsmShim, externalsPreset },\n );\n const isVirtual = serverFile.includes('\\n') || existsSync(serverFile);\n\n const toolsInputOptions = await this.listToolsInputOptions(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 getAllToolPaths(mastraDir: string, toolsPaths: (string | string[])[] = []): (string | string[])[] {\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedMastraDir = slash(mastraDir);\n\n // Prepare default tools paths with glob patterns\n const defaultToolsPath = posix.join(normalizedMastraDir, 'tools/**/*.{js,ts}');\n const defaultToolsIgnorePaths = [\n `!${posix.join(normalizedMastraDir, 'tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'tools/**/__tests__/**')}`,\n ];\n\n // Combine default path with ignore patterns\n const defaultPaths = [defaultToolsPath, ...defaultToolsIgnorePaths];\n\n // If no tools paths provided, use only the default paths\n if (toolsPaths.length === 0) {\n return [defaultPaths];\n }\n\n // If tools paths are provided, add the default paths to ensure standard tools are always included\n return [...toolsPaths, defaultPaths];\n }\n\n async listToolsInputOptions(toolsPaths: (string | string[])[]) {\n const inputs: Record<string, string> = {};\n\n for (const toolPath of toolsPaths) {\n const expandedPaths = await glob(toolPath, {\n absolute: true,\n expandDirectories: false,\n });\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 // Normalize Windows paths to forward slashes for consistent handling\n const normalizedEntryFile = entryFile.replaceAll('\\\\', '/');\n inputs[`tools/${uniqueToolID}`] = normalizedEntryFile;\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 {\n projectRoot,\n outputDirectory,\n enableEsmShim = true,\n externals = [],\n }: { projectRoot: string; outputDirectory: string; enableEsmShim?: boolean; externals?: boolean | string[] },\n toolsPaths: (string | string[])[] = [],\n bundleLocation: string = join(outputDirectory, this.outputDir),\n ): Promise<void> {\n const analyzeDir = join(outputDirectory, this.analyzeOutputDir);\n let sourcemap = false;\n let externalsPreset = false;\n\n try {\n const bundlerOptions = await getBundlerOptions(mastraEntryFile, analyzeDir);\n sourcemap = !!bundlerOptions?.sourcemap;\n externalsPreset = bundlerOptions?.externals === true;\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.listToolsInputOptions(toolsPaths);\n analyzedBundleInfo = await analyzeBundle(\n [serverFile, ...Object.values(resolvedToolsPaths)],\n mastraEntryFile,\n {\n outputDir: analyzeDir,\n projectRoot,\n platform: 'node',\n bundlerOptions: {\n externals,\n },\n },\n this.logger,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n if (error instanceof MastraError) {\n throw error;\n }\n\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 const dependenciesToInstall = new Map<string, string>();\n for (const dep of analyzedBundleInfo.externalDependencies) {\n try {\n if (analyzedBundleInfo.workspaceMap.has(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 || 'latest');\n } catch {\n dependenciesToInstall.set(dep, 'latest');\n }\n }\n\n try {\n await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall);\n\n this.logger.info('Bundling Mastra application');\n\n const inputOptions: InputOptions = await this.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n { enableSourcemap: sourcemap, enableEsmShim, externalsPreset },\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, rootDir: projectRoot });\n\n this.logger.info('Done copying .npmrc file');\n\n this.logger.info('Installing dependencies');\n await this.installDependencies(outputDirectory, projectRoot);\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.listToolsInputOptions(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,4 +1,5 @@
1
1
  import { join, relative, basename } from 'path';
2
+ import { builtinModules } from 'module';
2
3
 
3
4
  // src/build/utils.ts
4
5
  function isDependencyPartOfPackage(dep, packageName) {
@@ -51,7 +52,10 @@ function normalizeStudioBase(studioBase) {
51
52
  }
52
53
  return studioBase;
53
54
  }
55
+ function isBuiltinModule(specifier) {
56
+ return builtinModules.includes(specifier) || specifier.startsWith("node:") || builtinModules.includes(specifier.replace(/^node:/, ""));
57
+ }
54
58
 
55
- export { getCompiledDepCachePath, getPackageName, isDependencyPartOfPackage, normalizeStudioBase, rollupSafeName, slash };
56
- //# sourceMappingURL=chunk-NM6R77PX.js.map
57
- //# sourceMappingURL=chunk-NM6R77PX.js.map
59
+ export { getCompiledDepCachePath, getPackageName, isBuiltinModule, isDependencyPartOfPackage, normalizeStudioBase, rollupSafeName, slash };
60
+ //# sourceMappingURL=chunk-HHA2Y3AS.js.map
61
+ //# sourceMappingURL=chunk-HHA2Y3AS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/utils.ts"],"names":[],"mappings":";;;;AAcO,SAAS,yBAAA,CAA0B,KAAa,WAAA,EAAqB;AAC1E,EAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,GAAA,CAAI,UAAA,CAAW,CAAA,EAAG,WAAW,CAAA,CAAA,CAAG,CAAA;AACzC;AAKO,SAAS,eAAe,EAAA,EAAY;AACzC,EAAA,MAAM,KAAA,GAAQ,EAAA,CAAG,KAAA,CAAM,GAAG,CAAA;AAE1B,EAAA,IAAI,EAAA,CAAG,UAAA,CAAW,GAAG,CAAA,EAAG;AACtB,IAAA,OAAO,MAAM,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,CAAE,KAAK,GAAG,CAAA;AAAA,EACnC;AAEA,EAAA,OAAO,MAAM,CAAC,CAAA;AAChB;AAMO,SAAS,uBAAA,CAAwB,UAAkB,WAAA,EAAqB;AAC7E,EAAA,OAAO,MAAM,IAAA,CAAK,QAAA,EAAU,cAAA,EAAgB,QAAA,EAAU,WAAW,CAAC,CAAA;AACpE;AAUO,SAAS,MAAM,IAAA,EAAc;AAClC,EAAA,MAAM,oBAAA,GAAuB,IAAA,CAAK,UAAA,CAAW,SAAS,CAAA;AAEtD,EAAA,IAAI,oBAAA,EAAsB;AACxB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA,C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AG,CAAA,EAAG;AAC/B,IAAA,UAAA,GAAa,IAAI,UAAU,CAAA,CAAA;AAAA,EAC7B;AAEA,EAAA,OAAO,UAAA;AACT;AAOO,SAAS,gBAAgB,SAAA,EAA4B;AAC1D,EAAA,OACE,cAAA,CAAe,QAAA,CAAS,SAAS,CAAA,IACjC,UAAU,UAAA,CAAW,OAAO,CAAA,IAC5B,cAAA,CAAe,QAAA,CAAS,SAAA,CAAU,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAC,CAAA;AAE3D","file":"chunk-HHA2Y3AS.js","sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, mkdirSync } from 'node:fs';\nimport { basename, join, relative } from 'node:path';\nimport { builtinModules } from 'node:module';\n\nexport function upsertMastraDir({ dir = process.cwd() }: { dir?: string }) {\n const dirPath = join(dir, '.mastra');\n\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n execSync(`echo \".mastra\" >> .gitignore`);\n }\n}\n\nexport function isDependencyPartOfPackage(dep: string, packageName: string) {\n if (dep === packageName) {\n return true;\n }\n\n return dep.startsWith(`${packageName}/`);\n}\n\n/**\n * Get the package name from a module ID\n */\nexport function getPackageName(id: string) {\n const parts = id.split('/');\n\n if (id.startsWith('@')) {\n return parts.slice(0, 2).join('/');\n }\n\n return parts[0];\n}\n\n/**\n * During `mastra dev` we are compiling TS files to JS (inside workspaces) so that users can just their workspace packages.\n * We store these compiled files inside `node_modules/.cache` for each workspace package.\n */\nexport function getCompiledDepCachePath(rootPath: string, packageName: string) {\n return slash(join(rootPath, 'node_modules', '.cache', packageName));\n}\n\n/**\n * Convert windows backslashes to posix slashes\n *\n * @example\n * ```ts\n * slash('C:\\\\Users\\\\user\\\\code\\\\mastra') // 'C:/Users/user/code/mastra'\n * ```\n */\nexport function slash(path: string) {\n const isExtendedLengthPath = path.startsWith('\\\\\\\\?\\\\');\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll('\\\\', '/');\n}\n\n/**\n * Make a Rollup-safe name: pathless, POSIX, and without parent/absolute segments\n */\nexport function rollupSafeName(name: string, rootDir: string) {\n const rel = relative(rootDir, name);\n let entry = slash(rel);\n entry = entry.replace(/^(\\.\\.\\/)+/, '');\n entry = entry.replace(/^\\/+/, '');\n entry = entry.replace(/^[A-Za-z]:\\//, '');\n if (!entry) {\n entry = slash(basename(name));\n }\n return entry;\n}\n\n/**\n * Native binding loaders and infrastructure packages that should be ignored when identifying the actual package that requires native bindings\n */\nconst NATIVE_BINDING_LOADERS = [\n 'node-gyp-build',\n 'prebuild-install',\n 'bindings',\n 'node-addon-api',\n 'node-pre-gyp',\n 'nan', // Native Abstractions for Node.js\n] as const;\n\n/**\n * Finds the first real package from node_modules that likely contains native bindings, filtering out virtual modules and native binding loader infrastructure.\n *\n * @param moduleIds - Array of module IDs from a Rollup chunk\n * @returns The module ID of the actual native package, or undefined if not found\n *\n * @example\n * const moduleIds = [\n * '\\x00/path/node_modules/bcrypt/bcrypt.js?commonjs-module',\n * '/path/node_modules/node-gyp-build/index.js',\n * '/path/node_modules/bcrypt/bcrypt.js',\n * ];\n * findNativePackageModule(moduleIds); // Returns '/path/node_modules/bcrypt/bcrypt.js'\n */\nexport function findNativePackageModule(moduleIds: string[]): string | undefined {\n return moduleIds.find(id => {\n // Skip virtual modules (Rollup plugin-generated)\n if (id.startsWith('\\x00')) {\n return false;\n }\n\n // Must be from node_modules\n if (!id.includes('/node_modules/')) {\n return false;\n }\n\n // Skip native binding loader infrastructure\n for (const loader of NATIVE_BINDING_LOADERS) {\n if (id.includes(`/${loader}/`) || id.includes(`/${loader}@`)) {\n return false;\n }\n }\n\n return true;\n });\n}\n\n/**\n * Ensures that server.studioBase is normalized.\n *\n * - If server.studioBase is '/' or empty, returns empty string\n * - Normalizes multiple slashes to single slash (e.g., '//' → '/')\n * - Removes trailing slashes (e.g., '/admin/' → '/admin')\n * - Adds leading slash if missing (e.g., 'admin' → '/admin')\n *\n * @param studioBase - The studioBase path to normalize\n * @returns Normalized studioBase path string\n */\nexport function normalizeStudioBase(studioBase: string): string {\n // Validate: no path traversal, no query params, no special chars\n if (studioBase.includes('..') || studioBase.includes('?') || studioBase.includes('#')) {\n throw new Error(`Invalid base path: \"${studioBase}\". Base path cannot contain '..', '?', or '#'`);\n }\n\n // Normalize multiple slashes to single slash\n studioBase = studioBase.replace(/\\/+/g, '/');\n\n // Handle default value cases\n if (studioBase === '/' || studioBase === '') {\n return '';\n }\n\n // Remove trailing slash\n if (studioBase.endsWith('/')) {\n studioBase = studioBase.slice(0, -1);\n }\n\n // Add leading slash if missing\n if (!studioBase.startsWith('/')) {\n studioBase = `/${studioBase}`;\n }\n\n return studioBase;\n}\n\n/**\n * Check if a module is a Node.js builtin module\n * @param specifier - Module specifier\n * @returns True if it's a builtin module\n */\nexport function isBuiltinModule(specifier: string): boolean {\n return (\n builtinModules.includes(specifier) ||\n specifier.startsWith('node:') ||\n builtinModules.includes(specifier.replace(/^node:/, ''))\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkF2LCS2DV_cjs = require('./chunk-F2LCS2DV.cjs');
3
+ var chunkVA2CSOKJ_cjs = require('./chunk-VA2CSOKJ.cjs');
4
4
  var babel = require('@babel/core');
5
5
  var fs = require('fs');
6
6
  var promises = require('fs/promises');
@@ -129,7 +129,7 @@ globalThis.__dirname = dirname(__filename);
129
129
  "--input-type=module",
130
130
  "--enable-source-maps",
131
131
  "-e",
132
- `${prefixCode};import('file://${chunkF2LCS2DV_cjs.slash(file)}').catch(err => {
132
+ `${prefixCode};import('file://${chunkVA2CSOKJ_cjs.slash(file)}').catch(err => {
133
133
  ${errorHandler.toString()}
134
134
  errorHandler(err);
135
135
  })`.replaceAll(/\n/g, "")
@@ -578,7 +578,7 @@ async function getWorkspaceInformation({
578
578
  mastraEntryFile
579
579
  }) {
580
580
  const closestPkgJson = pkg__namespace.up({ cwd: path2.dirname(mastraEntryFile) });
581
- const location = closestPkgJson ? path2.dirname(chunkF2LCS2DV_cjs.slash(closestPkgJson)) : chunkF2LCS2DV_cjs.slash(process.cwd());
581
+ const location = closestPkgJson ? path2.dirname(chunkVA2CSOKJ_cjs.slash(closestPkgJson)) : chunkVA2CSOKJ_cjs.slash(process.cwd());
582
582
  const workspaces = await findWorkspaces.findWorkspaces(dir, { cache: workspacesCache });
583
583
  const _workspaceMap = new Map(
584
584
  workspaces?.map((workspace) => [
@@ -713,7 +713,7 @@ var DEPRECATED_EXTERNALS = ["fastembed", "nodemailer", "jsdom", "sqlite3"];
713
713
 
714
714
  // src/build/analyze/analyzeEntry.ts
715
715
  function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }) {
716
- const normalizedMastraEntry = chunkF2LCS2DV_cjs.slash(mastraEntry);
716
+ const normalizedMastraEntry = chunkVA2CSOKJ_cjs.slash(mastraEntry);
717
717
  let virtualPlugin = null;
718
718
  if (isVirtualFile) {
719
719
  virtualPlugin = virtual__default.default({
@@ -732,7 +732,7 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
732
732
  name: "custom-alias-resolver",
733
733
  resolveId(id) {
734
734
  if (id === "#server") {
735
- return chunkF2LCS2DV_cjs.slash(url.fileURLToPath(undefined("@mastra/deployer/server")));
735
+ return chunkVA2CSOKJ_cjs.slash(url.fileURLToPath(undefined("@mastra/deployer/server")));
736
736
  }
737
737
  if (id === "#mastra") {
738
738
  return normalizedMastraEntry;
@@ -774,14 +774,14 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
774
774
  if (isNodeBuiltin(dependency) || dependency.startsWith("#")) {
775
775
  continue;
776
776
  }
777
- const pkgName = chunkF2LCS2DV_cjs.getPackageName(dependency);
777
+ const pkgName = chunkVA2CSOKJ_cjs.getPackageName(dependency);
778
778
  let rootPath = null;
779
779
  let isWorkspace = false;
780
780
  if (pkgName) {
781
781
  rootPath = await getPackageRootPath(dependency, entryRootPath);
782
782
  isWorkspace = workspaceMap.has(pkgName);
783
783
  }
784
- const normalizedRootPath = rootPath ? chunkF2LCS2DV_cjs.slash(rootPath) : null;
784
+ const normalizedRootPath = rootPath ? chunkVA2CSOKJ_cjs.slash(rootPath) : null;
785
785
  depsToOptimize.set(dependency, {
786
786
  exports: bindings,
787
787
  rootPath: normalizedRootPath,
@@ -978,7 +978,7 @@ function subpathExternalsResolver(externals) {
978
978
  if (id.startsWith(".") || id.startsWith("/")) {
979
979
  return null;
980
980
  }
981
- const isPartOfExternals = externals.some((external) => chunkF2LCS2DV_cjs.isDependencyPartOfPackage(id, external));
981
+ const isPartOfExternals = externals.some((external) => chunkVA2CSOKJ_cjs.isDependencyPartOfPackage(id, external));
982
982
  if (isPartOfExternals) {
983
983
  return {
984
984
  id,
@@ -998,7 +998,7 @@ function moduleResolveMap(externals, projectRoot) {
998
998
  }
999
999
  for (const importedId of info.importedIds) {
1000
1000
  for (const external of externals) {
1001
- if (chunkF2LCS2DV_cjs.isDependencyPartOfPackage(importedId, external)) {
1001
+ if (chunkVA2CSOKJ_cjs.isDependencyPartOfPackage(importedId, external)) {
1002
1002
  importMap.set(external, info.id);
1003
1003
  }
1004
1004
  }
@@ -1010,9 +1010,9 @@ function moduleResolveMap(externals, projectRoot) {
1010
1010
  if (chunk.type === "chunk") {
1011
1011
  for (const [external, resolvedFrom] of importMap) {
1012
1012
  if (chunk.moduleIds.includes(resolvedFrom)) {
1013
- const fullPath = url.pathToFileURL(chunkF2LCS2DV_cjs.slash(path2.join(projectRoot, fileName))).toString();
1013
+ const fullPath = url.pathToFileURL(chunkVA2CSOKJ_cjs.slash(path2.join(projectRoot, fileName))).toString();
1014
1014
  const innerMap = resolveMap.get(fullPath) || /* @__PURE__ */ new Map();
1015
- innerMap.set(external, url.pathToFileURL(chunkF2LCS2DV_cjs.slash(resolvedFrom)).toString());
1015
+ innerMap.set(external, url.pathToFileURL(chunkVA2CSOKJ_cjs.slash(resolvedFrom)).toString());
1016
1016
  resolveMap.set(fullPath, innerMap);
1017
1017
  }
1018
1018
  }
@@ -1032,7 +1032,7 @@ function moduleResolveMap(externals, projectRoot) {
1032
1032
 
1033
1033
  // src/build/analyze/bundleExternals.ts
1034
1034
  function prepareEntryFileName(name, rootDir) {
1035
- return chunkF2LCS2DV_cjs.rollupSafeName(name, rootDir);
1035
+ return chunkVA2CSOKJ_cjs.rollupSafeName(name, rootDir);
1036
1036
  }
1037
1037
  function createVirtualDependencies(depsToOptimize, {
1038
1038
  projectRoot,
@@ -1040,7 +1040,7 @@ function createVirtualDependencies(depsToOptimize, {
1040
1040
  outputDir,
1041
1041
  bundlerOptions
1042
1042
  }) {
1043
- const { isDev = false } = bundlerOptions || {};
1043
+ const { isDev = false, externalsPreset = false } = bundlerOptions || {};
1044
1044
  const fileNameToDependencyMap = /* @__PURE__ */ new Map();
1045
1045
  const optimizedDependencyEntries = /* @__PURE__ */ new Map();
1046
1046
  const rootDir = workspaceRoot || projectRoot;
@@ -1072,7 +1072,7 @@ function createVirtualDependencies(depsToOptimize, {
1072
1072
  virtual: virtualFile.join("\n")
1073
1073
  });
1074
1074
  }
1075
- if (isDev) {
1075
+ if (isDev || externalsPreset) {
1076
1076
  for (const [dep, { isWorkspace, rootPath }] of depsToOptimize.entries()) {
1077
1077
  if (!isWorkspace || !rootPath || !workspaceRoot) {
1078
1078
  continue;
@@ -1082,7 +1082,7 @@ function createVirtualDependencies(depsToOptimize, {
1082
1082
  continue;
1083
1083
  }
1084
1084
  const fileName = posix.basename(currentDepPath.name);
1085
- const entryName = prepareEntryFileName(chunkF2LCS2DV_cjs.getCompiledDepCachePath(rootPath, fileName), rootDir);
1085
+ const entryName = prepareEntryFileName(chunkVA2CSOKJ_cjs.getCompiledDepCachePath(rootPath, fileName), rootDir);
1086
1086
  fileNameToDependencyMap.set(entryName, dep);
1087
1087
  optimizedDependencyEntries.set(dep, {
1088
1088
  ...currentDepPath,
@@ -1103,7 +1103,7 @@ async function getInputPlugins2(virtualDependencies, {
1103
1103
  for (const pkg2 of transpilePackages) {
1104
1104
  const dir = await getPackageRootPath(pkg2);
1105
1105
  if (dir) {
1106
- transpilePackagesMap.set(pkg2, chunkF2LCS2DV_cjs.slash(dir));
1106
+ transpilePackagesMap.set(pkg2, chunkVA2CSOKJ_cjs.slash(dir));
1107
1107
  } else {
1108
1108
  transpilePackagesMap.set(pkg2, workspaceMap.get(pkg2)?.location ?? pkg2);
1109
1109
  }
@@ -1129,7 +1129,7 @@ async function getInputPlugins2(virtualDependencies, {
1129
1129
  }
1130
1130
  })
1131
1131
  }) : null,
1132
- bundlerOptions.isDev ? {
1132
+ bundlerOptions.noBundling ? {
1133
1133
  name: "alias-optimized-deps",
1134
1134
  async resolveId(id, importer, options) {
1135
1135
  if (!virtualDependencies.has(id)) {
@@ -1159,11 +1159,11 @@ async function getInputPlugins2(virtualDependencies, {
1159
1159
  transformMixedEsModules: true,
1160
1160
  ignoreTryCatch: false
1161
1161
  }),
1162
- bundlerOptions.isDev ? null : nodeResolve__default.default({
1162
+ bundlerOptions.noBundling ? null : nodeResolve__default.default({
1163
1163
  preferBuiltins: true,
1164
1164
  exportConditions: ["node"]
1165
1165
  }),
1166
- bundlerOptions.isDev ? esmShim() : null,
1166
+ bundlerOptions.noBundling ? esmShim() : null,
1167
1167
  // hono is imported from deployer, so we need to resolve from here instead of the project root
1168
1168
  aliasHono(),
1169
1169
  json__default.default(),
@@ -1216,6 +1216,16 @@ async function buildExternalDependencies(virtualDependencies, {
1216
1216
  if (virtualDependencies.size === 0) {
1217
1217
  return [];
1218
1218
  }
1219
+ const noBundling = bundlerOptions.isDev || bundlerOptions.externalsPreset;
1220
+ const plugins = await getInputPlugins2(virtualDependencies, {
1221
+ transpilePackages: packagesToTranspile,
1222
+ workspaceMap,
1223
+ bundlerOptions: {
1224
+ noBundling
1225
+ },
1226
+ rootDir,
1227
+ externals
1228
+ });
1219
1229
  const bundler = await rollup.rollup({
1220
1230
  logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
1221
1231
  input: Array.from(virtualDependencies.entries()).reduce(
@@ -1226,14 +1236,8 @@ async function buildExternalDependencies(virtualDependencies, {
1226
1236
  {}
1227
1237
  ),
1228
1238
  external: externals,
1229
- treeshake: bundlerOptions.isDev ? false : "safest",
1230
- plugins: getInputPlugins2(virtualDependencies, {
1231
- transpilePackages: packagesToTranspile,
1232
- workspaceMap,
1233
- bundlerOptions,
1234
- rootDir,
1235
- externals
1236
- })
1239
+ treeshake: noBundling ? false : "safest",
1240
+ plugins
1237
1241
  });
1238
1242
  const outputDirRelative = prepareEntryFileName(outputDir, rootDir);
1239
1243
  const { output } = await bundler.write({
@@ -1247,12 +1251,12 @@ async function buildExternalDependencies(virtualDependencies, {
1247
1251
  * So we want to write them to the `.mastra/output` folder as well.
1248
1252
  */
1249
1253
  chunkFileNames: (chunkInfo) => {
1250
- if (bundlerOptions.isDev) {
1254
+ if (noBundling) {
1251
1255
  const importedFromPackages = /* @__PURE__ */ new Set();
1252
1256
  for (const moduleId of chunkInfo.moduleIds) {
1253
- const normalized = chunkF2LCS2DV_cjs.slash(moduleId);
1257
+ const normalized = chunkVA2CSOKJ_cjs.slash(moduleId);
1254
1258
  for (const [pkgName, pkgInfo] of workspaceMap.entries()) {
1255
- const location = chunkF2LCS2DV_cjs.slash(pkgInfo.location);
1259
+ const location = chunkVA2CSOKJ_cjs.slash(pkgInfo.location);
1256
1260
  if (normalized.startsWith(location)) {
1257
1261
  importedFromPackages.add(pkgName);
1258
1262
  break;
@@ -1274,7 +1278,7 @@ async function buildExternalDependencies(virtualDependencies, {
1274
1278
  if (importedFromPackages.size === 1) {
1275
1279
  const [pkgName] = importedFromPackages;
1276
1280
  const workspaceLocation = workspaceMap.get(pkgName).location;
1277
- return prepareEntryFileName(chunkF2LCS2DV_cjs.getCompiledDepCachePath(workspaceLocation, "[name].mjs"), rootDir);
1281
+ return prepareEntryFileName(chunkVA2CSOKJ_cjs.getCompiledDepCachePath(workspaceLocation, "[name].mjs"), rootDir);
1278
1282
  }
1279
1283
  }
1280
1284
  return `${outputDirRelative}/[name].mjs`;
@@ -1288,7 +1292,7 @@ async function buildExternalDependencies(virtualDependencies, {
1288
1292
  function findExternalImporter(module, external, allOutputs) {
1289
1293
  const capturedFiles = /* @__PURE__ */ new Set();
1290
1294
  for (const id of module.imports) {
1291
- if (chunkF2LCS2DV_cjs.isDependencyPartOfPackage(id, external)) {
1295
+ if (chunkVA2CSOKJ_cjs.isDependencyPartOfPackage(id, external)) {
1292
1296
  return module;
1293
1297
  } else {
1294
1298
  if (id.endsWith(".mjs")) {
@@ -1309,19 +1313,31 @@ function findExternalImporter(module, external, allOutputs) {
1309
1313
  }
1310
1314
  async function bundleExternals(depsToOptimize, outputDir, options) {
1311
1315
  const { workspaceRoot = null, workspaceMap = /* @__PURE__ */ new Map(), projectRoot = outputDir, bundlerOptions = {} } = options;
1312
- const {
1313
- externals: customExternals = [],
1314
- transpilePackages = [],
1315
- isDev = false} = bundlerOptions || {};
1316
- const allExternals = [...GLOBAL_EXTERNALS, ...DEPRECATED_EXTERNALS, ...customExternals];
1316
+ const { externals: customExternals = [], transpilePackages = [], isDev = false } = bundlerOptions || {};
1317
+ let externalsPreset = false;
1318
+ if (customExternals === true) {
1319
+ externalsPreset = true;
1320
+ }
1321
+ const externalsList = Array.isArray(customExternals) ? customExternals : [];
1322
+ const allExternals = [...GLOBAL_EXTERNALS, ...DEPRECATED_EXTERNALS, ...externalsList];
1317
1323
  const workspacePackagesNames = Array.from(workspaceMap.keys());
1318
1324
  const packagesToTranspile = /* @__PURE__ */ new Set([...transpilePackages, ...workspacePackagesNames]);
1325
+ const extractedExternals = /* @__PURE__ */ new Map();
1326
+ if (externalsPreset) {
1327
+ for (const [dep, metadata] of depsToOptimize.entries()) {
1328
+ if (!metadata.isWorkspace) {
1329
+ extractedExternals.set(dep, metadata.rootPath ?? dep);
1330
+ depsToOptimize.delete(dep);
1331
+ }
1332
+ }
1333
+ }
1319
1334
  const { optimizedDependencyEntries, fileNameToDependencyMap } = createVirtualDependencies(depsToOptimize, {
1320
1335
  workspaceRoot,
1321
1336
  outputDir,
1322
1337
  projectRoot,
1323
1338
  bundlerOptions: {
1324
- isDev
1339
+ isDev,
1340
+ externalsPreset
1325
1341
  }
1326
1342
  });
1327
1343
  const output = await buildExternalDependencies(optimizedDependencyEntries, {
@@ -1331,7 +1347,8 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
1331
1347
  rootDir: workspaceRoot || projectRoot,
1332
1348
  outputDir,
1333
1349
  bundlerOptions: {
1334
- isDev
1350
+ isDev,
1351
+ externalsPreset
1335
1352
  }
1336
1353
  });
1337
1354
  const moduleResolveMap2 = /* @__PURE__ */ new Map();
@@ -1366,6 +1383,14 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
1366
1383
  }
1367
1384
  usedExternals[fullPath] = innerObj;
1368
1385
  }
1386
+ if (extractedExternals.size > 0) {
1387
+ const syntheticPath = path2__namespace.join(workspaceRoot || projectRoot, "__externals__");
1388
+ const externalsObj = /* @__PURE__ */ Object.create(null);
1389
+ for (const [dep, rootPath] of extractedExternals) {
1390
+ externalsObj[dep] = rootPath;
1391
+ }
1392
+ usedExternals[syntheticPath] = externalsObj;
1393
+ }
1369
1394
  return { output, fileNameToDependencyMap, usedExternals };
1370
1395
  }
1371
1396
 
@@ -1641,7 +1666,7 @@ async function analyzeBundle(entries, mastraEntry, {
1641
1666
  outputDir,
1642
1667
  projectRoot,
1643
1668
  isDev = false,
1644
- bundlerOptions: _bundlerOptions
1669
+ bundlerOptions: internalBundlerOptions
1645
1670
  }, logger) {
1646
1671
  const mastraConfig = await promises.readFile(mastraEntry, "utf-8");
1647
1672
  const mastraConfigResult = {
@@ -1660,28 +1685,33 @@ export const mastra = new Mastra({
1660
1685
 
1661
1686
  If you think your configuration is valid, please open an issue.`);
1662
1687
  }
1663
- const { enableEsmShim = true } = _bundlerOptions || {};
1664
- const bundlerOptions = await getBundlerOptions(mastraEntry, outputDir);
1688
+ const { externals: _bundlerExternals = [] } = internalBundlerOptions || {};
1689
+ const userBundlerOptions = await getBundlerOptions(mastraEntry, outputDir);
1665
1690
  const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: mastraEntry });
1691
+ let externalsPreset = false;
1692
+ if (userBundlerOptions?.externals === true) {
1693
+ externalsPreset = true;
1694
+ }
1666
1695
  let index = 0;
1667
1696
  const depsToOptimize = /* @__PURE__ */ new Map();
1668
- const { externals: customExternals = [] } = bundlerOptions || {};
1669
- const allExternals = [...GLOBAL_EXTERNALS, ...customExternals];
1697
+ const bundlerExternals = Array.isArray(_bundlerExternals) ? _bundlerExternals : [];
1698
+ const userExternals = Array.isArray(userBundlerOptions?.externals) ? userBundlerOptions?.externals : [];
1699
+ const allExternals = [...GLOBAL_EXTERNALS, ...bundlerExternals, ...userExternals];
1670
1700
  logger.info("Analyzing dependencies...");
1671
1701
  const allUsedExternals = /* @__PURE__ */ new Set();
1672
1702
  for (const entry of entries) {
1673
1703
  const isVirtualFile = entry.includes("\n") || !fs.existsSync(entry);
1674
1704
  const analyzeResult = await analyzeEntry({ entry, isVirtualFile }, mastraEntry, {
1675
1705
  logger,
1676
- sourcemapEnabled: bundlerOptions?.sourcemap ?? false,
1706
+ sourcemapEnabled: userBundlerOptions?.sourcemap ?? false,
1677
1707
  workspaceMap,
1678
1708
  projectRoot,
1679
- shouldCheckTransitiveDependencies: isDev
1709
+ shouldCheckTransitiveDependencies: isDev || externalsPreset
1680
1710
  });
1681
1711
  await promises.writeFile(path2.join(outputDir, `entry-${index++}.mjs`), analyzeResult.output.code);
1682
1712
  for (const [dep, metadata] of analyzeResult.dependencies.entries()) {
1683
- const isPartOfExternals = allExternals.some((external) => chunkF2LCS2DV_cjs.isDependencyPartOfPackage(dep, external));
1684
- if (isPartOfExternals) {
1713
+ const isPartOfExternals = allExternals.some((external) => chunkVA2CSOKJ_cjs.isDependencyPartOfPackage(dep, external));
1714
+ if (isPartOfExternals || externalsPreset && !metadata.isWorkspace) {
1685
1715
  allUsedExternals.add(dep);
1686
1716
  continue;
1687
1717
  }
@@ -1696,7 +1726,7 @@ If you think your configuration is valid, please open an issue.`);
1696
1726
  }
1697
1727
  }
1698
1728
  }
1699
- if (isDev) {
1729
+ if (isDev || externalsPreset) {
1700
1730
  for (const [dep, metadata] of depsToOptimize.entries()) {
1701
1731
  if (!metadata.isWorkspace) {
1702
1732
  depsToOptimize.delete(dep);
@@ -1708,15 +1738,37 @@ If you think your configuration is valid, please open an issue.`);
1708
1738
  logger.debug(`${sortedDeps.map((key) => `- ${key}`).join("\n")}`);
1709
1739
  const { output, fileNameToDependencyMap, usedExternals } = await bundleExternals(depsToOptimize, outputDir, {
1710
1740
  bundlerOptions: {
1711
- ...bundlerOptions,
1712
- externals: allExternals,
1713
- enableEsmShim,
1741
+ ...userBundlerOptions,
1742
+ externals: userBundlerOptions?.externals ?? allExternals,
1714
1743
  isDev
1715
1744
  },
1716
1745
  projectRoot,
1717
1746
  workspaceRoot,
1718
1747
  workspaceMap
1719
1748
  });
1749
+ const relativeWorkspaceFolderPaths = Array.from(workspaceMap.values()).map(
1750
+ (pkgInfo) => path2.relative(workspaceRoot || projectRoot, pkgInfo.location)
1751
+ );
1752
+ for (const o of output) {
1753
+ if (o.type === "asset") {
1754
+ continue;
1755
+ }
1756
+ for (const i of o.imports) {
1757
+ if (chunkVA2CSOKJ_cjs.isBuiltinModule(i)) {
1758
+ continue;
1759
+ }
1760
+ if (i.startsWith(".") || i.startsWith("/")) {
1761
+ continue;
1762
+ }
1763
+ if (relativeWorkspaceFolderPaths.some((workspacePath) => i.startsWith(workspacePath))) {
1764
+ continue;
1765
+ }
1766
+ const pkgName = chunkVA2CSOKJ_cjs.getPackageName(i);
1767
+ if (pkgName) {
1768
+ allUsedExternals.add(pkgName);
1769
+ }
1770
+ }
1771
+ }
1720
1772
  const result = await validateOutput(
1721
1773
  {
1722
1774
  output,
@@ -1746,5 +1798,5 @@ exports.removeAllOptionsFromMastraExcept = removeAllOptionsFromMastraExcept;
1746
1798
  exports.removeDeployer = removeDeployer2;
1747
1799
  exports.subpathExternalsResolver = subpathExternalsResolver;
1748
1800
  exports.tsConfigPaths = tsConfigPaths;
1749
- //# sourceMappingURL=chunk-EHZKDGGA.cjs.map
1750
- //# sourceMappingURL=chunk-EHZKDGGA.cjs.map
1801
+ //# sourceMappingURL=chunk-KCGBR2X6.cjs.map
1802
+ //# sourceMappingURL=chunk-KCGBR2X6.cjs.map