@mastra/deployer 1.68.0-alpha.0 → 1.68.0-alpha.5

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 (115) hide show
  1. package/dist/_types/@hono_node-server/package.json +1 -0
  2. package/dist/_types/@mastra_hono/package.json +1 -0
  3. package/dist/{analyze-hp4aHpms.cjs → analyze-BC22OIkc.cjs} +109 -94
  4. package/dist/analyze-BC22OIkc.cjs.map +1 -0
  5. package/dist/{analyze-B5HY26Tt.js → analyze-D3eRdXC9.js} +107 -91
  6. package/dist/analyze-D3eRdXC9.js.map +1 -0
  7. package/dist/{arktype-aI7TBD0R-S0daSmHG.js → arktype-aI7TBD0R-BGjyzmsj.js} +2 -2
  8. package/dist/{arktype-aI7TBD0R-S0daSmHG.js.map → arktype-aI7TBD0R-BGjyzmsj.js.map} +1 -1
  9. package/dist/{arktype-aI7TBD0R-BuTX_Phx.cjs → arktype-aI7TBD0R-DCxjN6oF.cjs} +2 -2
  10. package/dist/{arktype-aI7TBD0R-BuTX_Phx.cjs.map → arktype-aI7TBD0R-DCxjN6oF.cjs.map} +1 -1
  11. package/dist/build/analyze/analyzeEntry.d.ts +3 -1
  12. package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
  13. package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
  14. package/dist/build/analyze.cjs +1 -1
  15. package/dist/build/analyze.d.ts.map +1 -1
  16. package/dist/build/analyze.js +1 -1
  17. package/dist/build/bundler.cjs +2 -1
  18. package/dist/build/bundler.d.ts +10 -0
  19. package/dist/build/bundler.d.ts.map +1 -1
  20. package/dist/build/bundler.js +2 -2
  21. package/dist/build/index.cjs +6 -6
  22. package/dist/build/index.js +6 -6
  23. package/dist/build/package-info.d.ts +4 -0
  24. package/dist/build/package-info.d.ts.map +1 -1
  25. package/dist/build/plugins/tsconfig-paths.d.ts +2 -1
  26. package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
  27. package/dist/{build-Boe3fe3L.js → build-C5eBQq1A.js} +6 -6
  28. package/dist/{build-Boe3fe3L.js.map → build-C5eBQq1A.js.map} +1 -1
  29. package/dist/{build-Dit9VFE2.cjs → build-D-GPvP7A.cjs} +6 -6
  30. package/dist/{build-Dit9VFE2.cjs.map → build-D-GPvP7A.cjs.map} +1 -1
  31. package/dist/bundler/index.cjs +29 -62
  32. package/dist/bundler/index.cjs.map +1 -1
  33. package/dist/bundler/index.d.ts +1 -11
  34. package/dist/bundler/index.d.ts.map +1 -1
  35. package/dist/bundler/index.js +30 -63
  36. package/dist/bundler/index.js.map +1 -1
  37. package/dist/bundler/workspaceDependencies.d.ts +1 -1
  38. package/dist/bundler/workspaceDependencies.d.ts.map +1 -1
  39. package/dist/{bundler-CzQiVHzN.js → bundler-CNFQP4Qm.js} +45 -10
  40. package/dist/bundler-CNFQP4Qm.js.map +1 -0
  41. package/dist/{bundler-BKf2S2r_.cjs → bundler-I4HUeik1.cjs} +55 -8
  42. package/dist/bundler-I4HUeik1.cjs.map +1 -0
  43. package/dist/{bundlerOptions-I2E5y2Wp.cjs → bundlerOptions-CkFbsVoE.cjs} +2 -2
  44. package/dist/{bundlerOptions-I2E5y2Wp.cjs.map → bundlerOptions-CkFbsVoE.cjs.map} +1 -1
  45. package/dist/{bundlerOptions-BSySFLb3.js → bundlerOptions-Dg4pdJsM.js} +2 -2
  46. package/dist/{bundlerOptions-BSySFLb3.js.map → bundlerOptions-Dg4pdJsM.js.map} +1 -1
  47. package/dist/core-D3wM1JKp.js +1159 -0
  48. package/dist/core-D3wM1JKp.js.map +1 -0
  49. package/dist/core-QL_X0T4Y.cjs +1159 -0
  50. package/dist/core-QL_X0T4Y.cjs.map +1 -0
  51. package/dist/docs/SKILL.md +1 -1
  52. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  53. package/dist/docs/references/docs-deployment-monorepo.md +2 -2
  54. package/dist/{effect-QlVUlMFu-tf02PTZR.cjs → effect-QlVUlMFu-B2nZ842E.cjs} +3 -3
  55. package/dist/{effect-QlVUlMFu-tf02PTZR.cjs.map → effect-QlVUlMFu-B2nZ842E.cjs.map} +1 -1
  56. package/dist/{effect-QlVUlMFu-BN-VJnMF.js → effect-QlVUlMFu-DbWuPaWV.js} +3 -3
  57. package/dist/{effect-QlVUlMFu-BN-VJnMF.js.map → effect-QlVUlMFu-DbWuPaWV.js.map} +1 -1
  58. package/dist/{esm-DZ1Siz1C.cjs → esm-Ai6osZ1a.cjs} +61 -50
  59. package/dist/esm-Ai6osZ1a.cjs.map +1 -0
  60. package/dist/{esm-B51vJPGv.js → esm-D-wYOO-S.js} +61 -50
  61. package/dist/esm-D-wYOO-S.js.map +1 -0
  62. package/dist/{index-CLddUTqr-eO-ae7Sx.js → index-CLddUTqr-BXqo9et4.js} +8 -8
  63. package/dist/{index-CLddUTqr-eO-ae7Sx.js.map → index-CLddUTqr-BXqo9et4.js.map} +1 -1
  64. package/dist/{index-CLddUTqr-DS5tJ3WV.cjs → index-CLddUTqr-DsGkVS-W.cjs} +8 -8
  65. package/dist/{index-CLddUTqr-DS5tJ3WV.cjs.map → index-CLddUTqr-DsGkVS-W.cjs.map} +1 -1
  66. package/dist/index.cjs +3 -3
  67. package/dist/index.js +3 -3
  68. package/dist/server/index.cjs +8 -8
  69. package/dist/server/index.cjs.map +1 -1
  70. package/dist/server/index.d.ts +2 -2
  71. package/dist/server/index.js +8 -8
  72. package/dist/server/index.js.map +1 -1
  73. package/dist/services/deps.d.ts +1 -1
  74. package/dist/services/deps.d.ts.map +1 -1
  75. package/dist/services/index.cjs +1 -1
  76. package/dist/services/index.js +1 -1
  77. package/dist/{services-BLvNG7v7.cjs → services-Beob47UW.cjs} +42 -23
  78. package/dist/services-Beob47UW.cjs.map +1 -0
  79. package/dist/{services-B9KRKBT-.js → services-Lm6PRS4D.js} +42 -23
  80. package/dist/services-Lm6PRS4D.js.map +1 -0
  81. package/dist/{sury-CWZTCd75-YUPbTtKO.cjs → sury-CWZTCd75-ChXu4j-p.cjs} +3 -3
  82. package/dist/{sury-CWZTCd75-YUPbTtKO.cjs.map → sury-CWZTCd75-ChXu4j-p.cjs.map} +1 -1
  83. package/dist/{sury-CWZTCd75-ClSNrMWF.js → sury-CWZTCd75-OKz7uWLi.js} +3 -3
  84. package/dist/{sury-CWZTCd75-ClSNrMWF.js.map → sury-CWZTCd75-OKz7uWLi.js.map} +1 -1
  85. package/dist/{typebox-Dei93FPO-CVSJ3SAf.js → typebox-Dei93FPO-C5ACKU09.js} +2 -2
  86. package/dist/{typebox-Dei93FPO-CVSJ3SAf.js.map → typebox-Dei93FPO-C5ACKU09.js.map} +1 -1
  87. package/dist/{typebox-Dei93FPO-BTBshlGz.cjs → typebox-Dei93FPO-KTtPU745.cjs} +2 -2
  88. package/dist/{typebox-Dei93FPO-BTBshlGz.cjs.map → typebox-Dei93FPO-KTtPU745.cjs.map} +1 -1
  89. package/dist/{utils-DYi43Kp4.js → utils-Bl3Lm7SI.js} +1 -2
  90. package/dist/{utils-DYi43Kp4.js.map → utils-Bl3Lm7SI.js.map} +1 -1
  91. package/dist/{utils-7WDNT3Ca.cjs → utils-Bsr_sEcH.cjs} +2 -2
  92. package/dist/{utils-7WDNT3Ca.cjs.map → utils-Bsr_sEcH.cjs.map} +1 -1
  93. package/dist/{valibot--1zFm7rT-Dn5WqdyK.cjs → valibot--1zFm7rT-BeX3W1HK.cjs} +3 -3
  94. package/dist/{valibot--1zFm7rT-Dn5WqdyK.cjs.map → valibot--1zFm7rT-BeX3W1HK.cjs.map} +1 -1
  95. package/dist/{valibot--1zFm7rT-BxcEC3Pu.js → valibot--1zFm7rT-BuVb-6oJ.js} +3 -3
  96. package/dist/{valibot--1zFm7rT-BxcEC3Pu.js.map → valibot--1zFm7rT-BuVb-6oJ.js.map} +1 -1
  97. package/dist/validator/custom-resolver.cjs +1 -1
  98. package/dist/validator/custom-resolver.js +1 -1
  99. package/dist/{zod-Bwrt9trS-Bd40XYOT.js → zod-Bwrt9trS-D5b1oyiT.js} +5 -5
  100. package/dist/{zod-Bwrt9trS-Bd40XYOT.js.map → zod-Bwrt9trS-D5b1oyiT.js.map} +1 -1
  101. package/dist/{zod-Bwrt9trS-Bi11nE9Q.cjs → zod-Bwrt9trS-DGQs9DWc.cjs} +5 -5
  102. package/dist/{zod-Bwrt9trS-Bi11nE9Q.cjs.map → zod-Bwrt9trS-DGQs9DWc.cjs.map} +1 -1
  103. package/package.json +13 -12
  104. package/dist/analyze-B5HY26Tt.js.map +0 -1
  105. package/dist/analyze-hp4aHpms.cjs.map +0 -1
  106. package/dist/bundler-BKf2S2r_.cjs.map +0 -1
  107. package/dist/bundler-CzQiVHzN.js.map +0 -1
  108. package/dist/core-D0wEgdn3.cjs +0 -790
  109. package/dist/core-D0wEgdn3.cjs.map +0 -1
  110. package/dist/core-DF65PJXc.js +0 -790
  111. package/dist/core-DF65PJXc.js.map +0 -1
  112. package/dist/esm-B51vJPGv.js.map +0 -1
  113. package/dist/esm-DZ1Siz1C.cjs.map +0 -1
  114. package/dist/services-B9KRKBT-.js.map +0 -1
  115. package/dist/services-BLvNG7v7.cjs.map +0 -1
@@ -1,7 +1,6 @@
1
- import { a as getPackageName, c as isBuiltinModule, f as rollupSafeName, i as getNodeResolveOptions, l as isDependencyPartOfPackage, m as slash, r as getCompiledDepCachePath, s as isBareModuleSpecifier, u as isExternalProtocolImport } from "./utils-DYi43Kp4.js";
2
- import { i as DepsService } from "./services-B9KRKBT-.js";
3
- import { a as tsConfigPaths, c as protocolExternalResolver, d as getPackageRootPath, f as esmShim, i as mastraToolsAliasPlugin, o as subpathExternalsResolver, p as esbuild, r as mastraInternalAliasPlugin, s as removeDeployer, u as getPackageMetadata } from "./bundler-CzQiVHzN.js";
4
- import { spawn } from "child_process";
1
+ import { a as getPackageName, c as isBuiltinModule, f as rollupSafeName, i as getNodeResolveOptions, l as isDependencyPartOfPackage, m as slash, r as getCompiledDepCachePath, s as isBareModuleSpecifier, u as isExternalProtocolImport } from "./utils-Bl3Lm7SI.js";
2
+ import { i as DepsService } from "./services-Lm6PRS4D.js";
3
+ import { a as mastraToolsAliasPlugin, c as removeDeployer, d as getPackageInfo$1, f as getPackageMetadata, h as esbuild, i as mastraInternalAliasPlugin, l as protocolExternalResolver, m as esmShim, o as tsConfigPaths, p as getPackageRootPath, s as subpathExternalsResolver } from "./bundler-CNFQP4Qm.js";
5
4
  import { existsSync } from "fs";
6
5
  import { readFile, writeFile } from "fs/promises";
7
6
  import * as path$1 from "path";
@@ -10,16 +9,16 @@ import { ErrorCategory, ErrorDomain, MastraBaseError, MastraError } from "@mastr
10
9
  import virtual from "@rollup/plugin-virtual";
11
10
  import * as pkg from "empathic/package";
12
11
  import { transformAsync, transformSync, types } from "@babel/core";
13
- import slugify from "@sindresorhus/slugify";
14
12
  import { createWorkspacesCache, findWorkspaces, findWorkspacesRoot } from "find-workspaces";
15
13
  import { ensureDir } from "fs-extra";
14
+ import { spawn } from "child_process";
16
15
  import { fileURLToPath, pathToFileURL } from "url";
17
16
  import commonjs from "@rollup/plugin-commonjs";
18
17
  import json from "@rollup/plugin-json";
18
+ import { getPackageInfo, resolveModule } from "local-pkg";
19
19
  import { rollup } from "rollup";
20
20
  import { optimizeLodashImports } from "@optimize-lodash/rollup-plugin";
21
21
  import nodeResolve from "@rollup/plugin-node-resolve";
22
- import { getPackageInfo } from "local-pkg";
23
22
  import { basename as basename$1 } from "path/posix";
24
23
  import * as resolve$1 from "resolve.exports";
25
24
  //#region \0rolldown/runtime.js
@@ -139,24 +138,6 @@ var import_stack_trace_parser_cjs = /* @__PURE__ */ __toESM((/* @__PURE__ */ __c
139
138
  }
140
139
  exports.parse = parse;
141
140
  })))(), 1);
142
- const isExportTargetImportable = (target) => {
143
- if (!target) return false;
144
- if (typeof target === "string") return true;
145
- if (Array.isArray(target)) return target.some(isExportTargetImportable);
146
- if (typeof target !== "object") return false;
147
- return Object.values(target).some(isExportTargetImportable);
148
- };
149
- const hasRootExport = (exportsField) => {
150
- if (exportsField === void 0) return true;
151
- if (typeof exportsField === "string" || Array.isArray(exportsField)) return isExportTargetImportable(exportsField);
152
- if (!exportsField || typeof exportsField !== "object") return false;
153
- const exportMap = exportsField;
154
- const exportKeys = Object.keys(exportMap);
155
- if (exportKeys.length === 0) return false;
156
- if (Object.prototype.hasOwnProperty.call(exportMap, ".")) return isExportTargetImportable(exportMap["."]);
157
- if (exportKeys.some((key) => key.startsWith("./"))) return false;
158
- return isExportTargetImportable(exportMap);
159
- };
160
141
  /**
161
142
  * Create a shared cache for find-workspaces
162
143
  */
@@ -193,7 +174,7 @@ async function getWorkspaceInformation({ dir = process.cwd(), mastraEntryFile })
193
174
  /**
194
175
  * Collects all transitive workspace dependencies and their TGZ paths
195
176
  */
196
- const collectTransitiveWorkspaceDependencies = ({ workspaceMap, initialDependencies, logger }) => {
177
+ const collectTransitiveWorkspaceDependencies = async ({ workspaceMap, initialDependencies, logger }) => {
197
178
  const usedWorkspacePackages = /* @__PURE__ */ new Set();
198
179
  const queue = Array.from(initialDependencies);
199
180
  const resolutions = {};
@@ -208,6 +189,7 @@ const collectTransitiveWorkspaceDependencies = ({ workspaceMap, initialDependenc
208
189
  if (!root) throw new Error("Could not find workspace root");
209
190
  const depsService = new DepsService(root.location);
210
191
  depsService.__setLogger(logger);
192
+ const slugify = (await import("@sindresorhus/slugify")).default;
211
193
  const sanitizedName = slugify(pkgName);
212
194
  resolutions[pkgName] = depsService.getWorkspaceDependencyPath({
213
195
  pkgName: sanitizedName,
@@ -231,6 +213,7 @@ const packWorkspaceDependencies = async ({ workspaceMap, usedWorkspacePackages,
231
213
  const depsService = new DepsService(root.location);
232
214
  depsService.__setLogger(logger);
233
215
  if (usedWorkspacePackages.size > 0) {
216
+ const slugify = (await import("@sindresorhus/slugify")).default;
234
217
  const workspaceDirPath = join(bundleOutputDir, "workspace-module");
235
218
  await ensureDir(workspaceDirPath);
236
219
  logger.info("Packaging workspace dependencies", { count: usedWorkspacePackages.size });
@@ -405,7 +388,7 @@ function getInputPlugins$1({ entry, isVirtualFile }, mastraEntry, { sourcemapEna
405
388
  * Analyzes both static imports and dynamic imports while filtering out Node.js built-ins and ignored dependencies.
406
389
  * Identifies workspace packages and resolves package root paths for proper bundling optimization.
407
390
  */
408
- async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, shouldCheckTransitiveDependencies }) {
391
+ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, mastraEntry, shouldCheckTransitiveDependencies, analyzeCache, activeEntries }) {
409
392
  const depsToOptimize = /* @__PURE__ */ new Map();
410
393
  if (!output.facadeModuleId) throw new Error("Something went wrong, we could not find the package name of the entry file. Please open an issue.");
411
394
  let entryRootPath = projectRoot;
@@ -433,47 +416,55 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
433
416
  packageSpec
434
417
  });
435
418
  }
436
- const processedWorkspaceDeps = /* @__PURE__ */ new Set();
419
+ const processedWorkspaceEntries = /* @__PURE__ */ new Set();
437
420
  /**
438
421
  * Recursively discovers transitive workspace dependencies from package manifests.
439
422
  */
440
- function checkTransitiveDependencies(maxDepth = 10, currentDepth = 0) {
441
- if (currentDepth >= maxDepth) {
442
- logger.warn("Maximum dependency depth reached while checking transitive dependencies.");
443
- return;
444
- }
423
+ async function checkTransitiveDependencies() {
445
424
  const depsSnapshot = new Map(depsToOptimize);
446
- let hasAddedDeps = false;
447
425
  for (const [dep, meta] of depsSnapshot) {
448
- const pkgName = getPackageName(dep);
449
- if (!pkgName || !meta.isWorkspace || processedWorkspaceDeps.has(pkgName)) continue;
450
- processedWorkspaceDeps.add(pkgName);
451
- const workspaceInfo = workspaceMap.get(pkgName);
452
- if (!workspaceInfo?.dependencies) continue;
453
- for (const [innerDep, _innerDepVersion] of Object.entries(workspaceInfo.dependencies)) {
454
- const innerWorkspaceInfo = workspaceMap.get(innerDep);
455
- if (!innerWorkspaceInfo) continue;
456
- if (!hasRootExport(innerWorkspaceInfo.exports)) continue;
426
+ if (!getPackageName(dep) || !meta.isWorkspace) continue;
427
+ const importerPath = pathToFileURL(output.facadeModuleId.startsWith("\0virtual:") ? mastraEntry || projectRoot : output.facadeModuleId).href;
428
+ const resolvedPath = resolveModule(dep, { paths: [importerPath] });
429
+ if (!resolvedPath) {
430
+ logger.warn("Could not resolve path for workspace dependency", { dep });
431
+ continue;
432
+ }
433
+ const resolvedEntry = slash(resolvedPath);
434
+ if (processedWorkspaceEntries.has(resolvedEntry) || activeEntries.has(resolvedEntry)) continue;
435
+ processedWorkspaceEntries.add(resolvedEntry);
436
+ const analysis = await analyzeEntry({
437
+ entry: resolvedPath,
438
+ isVirtualFile: false
439
+ }, mastraEntry, {
440
+ workspaceMap,
441
+ projectRoot,
442
+ logger,
443
+ sourcemapEnabled: false,
444
+ shouldCheckTransitiveDependencies: true,
445
+ analyzeCache,
446
+ activeEntries
447
+ });
448
+ if (!analysis?.dependencies) continue;
449
+ for (const [innerDep, innerMeta] of analysis.dependencies) {
450
+ if (!innerMeta.isWorkspace) continue;
457
451
  const existingMeta = depsToOptimize.get(innerDep);
458
452
  if (existingMeta) {
459
453
  depsToOptimize.set(innerDep, {
460
454
  ...existingMeta,
461
- exports: existingMeta.exports.includes("*") ? existingMeta.exports : [...existingMeta.exports, "*"]
455
+ exports: [.../* @__PURE__ */ new Set([...existingMeta.exports, ...innerMeta.exports])]
462
456
  });
463
457
  continue;
464
- }
465
- depsToOptimize.set(innerDep, {
466
- exports: ["*"],
467
- rootPath: slash(innerWorkspaceInfo.location),
458
+ } else depsToOptimize.set(innerDep, {
459
+ exports: innerMeta.exports,
460
+ rootPath: slash(innerMeta.rootPath || ""),
468
461
  isWorkspace: true,
469
- version: innerWorkspaceInfo.version
462
+ version: innerMeta.version
470
463
  });
471
- hasAddedDeps = true;
472
464
  }
473
465
  }
474
- if (hasAddedDeps) checkTransitiveDependencies(maxDepth, currentDepth + 1);
475
466
  }
476
- if (shouldCheckTransitiveDependencies) checkTransitiveDependencies();
467
+ if (shouldCheckTransitiveDependencies) await checkTransitiveDependencies();
477
468
  const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
478
469
  if (dynamicImports.length) {
479
470
  for (const dynamicImport of dynamicImports) if (!depsToOptimize.has(dynamicImport) && isBareModuleSpecifier(dynamicImport)) {
@@ -498,37 +489,54 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
498
489
  }
499
490
  return depsToOptimize;
500
491
  }
501
- async function analyzeEntry({ entry, isVirtualFile }, mastraEntry, { logger, sourcemapEnabled, workspaceMap, projectRoot, shouldCheckTransitiveDependencies = false, analyzeCache }) {
502
- const cacheKey = isVirtualFile ? void 0 : slash(entry);
503
- if (cacheKey && analyzeCache?.has(cacheKey)) return analyzeCache.get(cacheKey);
504
- const optimizerBundler = await rollup({
505
- logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
506
- input: isVirtualFile ? "#entry" : entry,
507
- treeshake: false,
508
- preserveSymlinks: true,
509
- plugins: getInputPlugins$1({
510
- entry,
511
- isVirtualFile
512
- }, mastraEntry, { sourcemapEnabled }),
513
- external: DEPS_TO_IGNORE
514
- });
515
- const { output } = await optimizerBundler.generate({
516
- format: "esm",
517
- inlineDynamicImports: true
518
- });
519
- await optimizerBundler.close();
520
- const result = {
521
- dependencies: await captureDependenciesToOptimize(output[0], workspaceMap, projectRoot, {
522
- logger,
523
- shouldCheckTransitiveDependencies
524
- }),
525
- output: {
526
- code: output[0].code,
527
- map: output[0].map
528
- }
529
- };
530
- if (cacheKey && analyzeCache) analyzeCache.set(cacheKey, result);
531
- return result;
492
+ async function analyzeEntry({ entry, isVirtualFile }, mastraEntry, { logger, sourcemapEnabled, workspaceMap, projectRoot, shouldCheckTransitiveDependencies = false, analyzeCache, activeEntries: providedActiveEntries }) {
493
+ const resolvedEntry = isVirtualFile ? void 0 : slash(entry);
494
+ const effectiveAnalyzeCache = analyzeCache ?? /* @__PURE__ */ new Map();
495
+ const cacheKey = resolvedEntry ? `${resolvedEntry}:${shouldCheckTransitiveDependencies ? "transitive" : "direct"}` : void 0;
496
+ if (cacheKey && effectiveAnalyzeCache.has(cacheKey)) return effectiveAnalyzeCache.get(cacheKey);
497
+ const activeEntries = providedActiveEntries ?? /* @__PURE__ */ new Set();
498
+ const shouldTrackEntry = Boolean(resolvedEntry && !activeEntries.has(resolvedEntry));
499
+ if (resolvedEntry && shouldTrackEntry) activeEntries.add(resolvedEntry);
500
+ try {
501
+ const optimizerBundler = await rollup({
502
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
503
+ input: isVirtualFile ? "#entry" : entry,
504
+ treeshake: false,
505
+ preserveSymlinks: true,
506
+ plugins: getInputPlugins$1({
507
+ entry,
508
+ isVirtualFile
509
+ }, mastraEntry, { sourcemapEnabled }),
510
+ external: DEPS_TO_IGNORE
511
+ });
512
+ const { output } = await (async () => {
513
+ try {
514
+ return await optimizerBundler.generate({
515
+ format: "esm",
516
+ inlineDynamicImports: true
517
+ });
518
+ } finally {
519
+ await optimizerBundler.close();
520
+ }
521
+ })();
522
+ const result = {
523
+ dependencies: await captureDependenciesToOptimize(output[0], workspaceMap, projectRoot, {
524
+ logger,
525
+ mastraEntry,
526
+ shouldCheckTransitiveDependencies,
527
+ analyzeCache: effectiveAnalyzeCache,
528
+ activeEntries
529
+ }),
530
+ output: {
531
+ code: output[0].code,
532
+ map: output[0].map
533
+ }
534
+ };
535
+ if (cacheKey) effectiveAnalyzeCache.set(cacheKey, result);
536
+ return result;
537
+ } finally {
538
+ if (resolvedEntry && shouldTrackEntry) activeEntries.delete(resolvedEntry);
539
+ }
532
540
  }
533
541
  //#endregion
534
542
  //#region src/build/plugins/hono-alias.ts
@@ -653,7 +661,7 @@ function createVirtualDependencies(depsToOptimize, { projectRoot, workspaceRoot,
653
661
  * Configures and returns Rollup plugins for bundling external dependencies.
654
662
  * Sets up virtual modules, TypeScript compilation, CommonJS transformation, and workspace resolution.
655
663
  */
656
- async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, rootDir, externals, platform }) {
664
+ async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, projectRoot, rootDir, externals, platform }) {
657
665
  const transpilePackagesMap = /* @__PURE__ */ new Map();
658
666
  for (const pkg of transpilePackages) {
659
667
  const dir = await getPackageRootPath(pkg);
@@ -665,7 +673,7 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
665
673
  acc[`#virtual-${dep}`] = virtualDep.virtual;
666
674
  return acc;
667
675
  }, {})),
668
- tsConfigPaths(),
676
+ tsConfigPaths({ cwd: projectRoot }),
669
677
  protocolExternalResolver(),
670
678
  subpathExternalsResolver(externals),
671
679
  transpilePackagesMap.size ? esbuild({
@@ -700,7 +708,11 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
700
708
  transformMixedEsModules: true,
701
709
  ignoreTryCatch: false
702
710
  }),
703
- bundlerOptions.noBundling ? null : nodeResolve(getNodeResolveOptions(platform)),
711
+ bundlerOptions.noBundling ? null : nodeResolve({
712
+ ...getNodeResolveOptions(platform),
713
+ rootDir: projectRoot,
714
+ modulePaths: [path$1.join(rootDir, "node_modules")]
715
+ }),
704
716
  bundlerOptions.noBundling ? esmShim() : null,
705
717
  aliasHono(),
706
718
  json(),
@@ -713,7 +725,7 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
713
725
  async handler(id, importer) {
714
726
  if (!importer) return null;
715
727
  if (!id.endsWith(".node")) return null;
716
- const packageName = (await getPackageInfo(importer))?.packageJson?.name || id;
728
+ const packageName = (await getPackageInfo$1(importer))?.packageJson?.name || id;
717
729
  throw new MastraBaseError({
718
730
  id: "DEPLOYER_BUNDLE_EXTERNALS_MISSING_NATIVE_BUILD",
719
731
  domain: ErrorDomain.DEPLOYER,
@@ -741,7 +753,7 @@ export const mastra = new Mastra({
741
753
  * Executes the Rollup build process for virtual dependencies using configured plugins.
742
754
  * Bundles all virtual dependency modules into optimized ESM files with proper external handling.
743
755
  */
744
- async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, rootDir, outputDir, bundlerOptions, platform }) {
756
+ async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, projectRoot, rootDir, outputDir, bundlerOptions, platform }) {
745
757
  /**
746
758
  * If there are no virtual dependencies to bundle, return an empty array to avoid Rollup errors.
747
759
  */
@@ -751,6 +763,7 @@ async function buildExternalDependencies(virtualDependencies, { externals, packa
751
763
  transpilePackages: packagesToTranspile,
752
764
  workspaceMap,
753
765
  bundlerOptions: { noBundling },
766
+ projectRoot,
754
767
  rootDir,
755
768
  externals,
756
769
  platform
@@ -873,6 +886,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
873
886
  externals: mergedExternals,
874
887
  packagesToTranspile,
875
888
  workspaceMap,
889
+ projectRoot,
876
890
  rootDir: workspaceRoot || projectRoot,
877
891
  outputDir,
878
892
  bundlerOptions: {
@@ -924,13 +938,13 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
924
938
  //#endregion
925
939
  //#region src/build/analyze/externals.ts
926
940
  function normalizeExternals(externals) {
927
- const userExternals = Array.isArray(externals) ? externals : [];
941
+ const explicitExternals = Array.isArray(externals) ? externals : [];
928
942
  return {
929
943
  externalsPreset: externals === true,
930
944
  mergedExternals: [...new Set([
931
945
  ...GLOBAL_EXTERNALS,
932
946
  ...DEPRECATED_EXTERNALS,
933
- ...userExternals
947
+ ...explicitExternals
934
948
  ].filter(Boolean))]
935
949
  };
936
950
  }
@@ -1272,6 +1286,7 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
1272
1286
  logger.info("Analyzing dependencies...");
1273
1287
  const allUsedExternals = /* @__PURE__ */ new Map();
1274
1288
  const analyzeCache = /* @__PURE__ */ new Map();
1289
+ const activeAnalyzeEntries = /* @__PURE__ */ new Set();
1275
1290
  for (const entry of entries) {
1276
1291
  const analyzeResult = await analyzeEntry({
1277
1292
  entry,
@@ -1282,7 +1297,8 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
1282
1297
  workspaceMap,
1283
1298
  projectRoot,
1284
1299
  shouldCheckTransitiveDependencies: true,
1285
- analyzeCache
1300
+ analyzeCache,
1301
+ activeEntries: activeAnalyzeEntries
1286
1302
  });
1287
1303
  transformSync(analyzeResult.output.code, {
1288
1304
  filename: "pino-detection.js",
@@ -1400,4 +1416,4 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
1400
1416
  //#endregion
1401
1417
  export { aliasHono as a, packWorkspaceDependencies as c, bundleExternals as i, checkConfigExport as n, collectTransitiveWorkspaceDependencies as o, normalizeExternals as r, getWorkspaceInformation as s, analyzeBundle as t };
1402
1418
 
1403
- //# sourceMappingURL=analyze-B5HY26Tt.js.map
1419
+ //# sourceMappingURL=analyze-D3eRdXC9.js.map