@mastra/deployer 1.67.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 +15 -14
  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
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -1,8 +1,7 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
2
- const require_utils = require("./utils-7WDNT3Ca.cjs");
3
- const require_services = require("./services-BLvNG7v7.cjs");
4
- const require_bundler = require("./bundler-BKf2S2r_.cjs");
5
- let child_process = require("child_process");
2
+ const require_utils = require("./utils-Bsr_sEcH.cjs");
3
+ const require_services = require("./services-Beob47UW.cjs");
4
+ const require_bundler = require("./bundler-I4HUeik1.cjs");
6
5
  let fs = require("fs");
7
6
  let fs_promises = require("fs/promises");
8
7
  let path = require("path");
@@ -13,20 +12,19 @@ _rollup_plugin_virtual = require_rolldown_runtime.__toESM(_rollup_plugin_virtual
13
12
  let empathic_package = require("empathic/package");
14
13
  empathic_package = require_rolldown_runtime.__toESM(empathic_package, 1);
15
14
  let _babel_core = require("@babel/core");
16
- let _sindresorhus_slugify = require("@sindresorhus/slugify");
17
- _sindresorhus_slugify = require_rolldown_runtime.__toESM(_sindresorhus_slugify, 1);
18
15
  let find_workspaces = require("find-workspaces");
19
16
  let fs_extra = require("fs-extra");
17
+ let child_process = require("child_process");
20
18
  let url = require("url");
21
19
  let _rollup_plugin_commonjs = require("@rollup/plugin-commonjs");
22
20
  _rollup_plugin_commonjs = require_rolldown_runtime.__toESM(_rollup_plugin_commonjs, 1);
23
21
  let _rollup_plugin_json = require("@rollup/plugin-json");
24
22
  _rollup_plugin_json = require_rolldown_runtime.__toESM(_rollup_plugin_json, 1);
23
+ let local_pkg = require("local-pkg");
25
24
  let rollup = require("rollup");
26
25
  let _optimize_lodash_rollup_plugin = require("@optimize-lodash/rollup-plugin");
27
26
  let _rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
28
27
  _rollup_plugin_node_resolve = require_rolldown_runtime.__toESM(_rollup_plugin_node_resolve, 1);
29
- let local_pkg = require("local-pkg");
30
28
  let path_posix = require("path/posix");
31
29
  let resolve_exports = require("resolve.exports");
32
30
  resolve_exports = require_rolldown_runtime.__toESM(resolve_exports, 1);
@@ -127,24 +125,6 @@ var require_stack_trace_parser_cjs = /* @__PURE__ */ require_rolldown_runtime.__
127
125
  //#endregion
128
126
  //#region src/bundler/workspaceDependencies.ts
129
127
  var import_stack_trace_parser_cjs = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_stack_trace_parser_cjs(), 1);
130
- const isExportTargetImportable = (target) => {
131
- if (!target) return false;
132
- if (typeof target === "string") return true;
133
- if (Array.isArray(target)) return target.some(isExportTargetImportable);
134
- if (typeof target !== "object") return false;
135
- return Object.values(target).some(isExportTargetImportable);
136
- };
137
- const hasRootExport = (exportsField) => {
138
- if (exportsField === void 0) return true;
139
- if (typeof exportsField === "string" || Array.isArray(exportsField)) return isExportTargetImportable(exportsField);
140
- if (!exportsField || typeof exportsField !== "object") return false;
141
- const exportMap = exportsField;
142
- const exportKeys = Object.keys(exportMap);
143
- if (exportKeys.length === 0) return false;
144
- if (Object.prototype.hasOwnProperty.call(exportMap, ".")) return isExportTargetImportable(exportMap["."]);
145
- if (exportKeys.some((key) => key.startsWith("./"))) return false;
146
- return isExportTargetImportable(exportMap);
147
- };
148
128
  /**
149
129
  * Create a shared cache for find-workspaces
150
130
  */
@@ -181,7 +161,7 @@ async function getWorkspaceInformation({ dir = process.cwd(), mastraEntryFile })
181
161
  /**
182
162
  * Collects all transitive workspace dependencies and their TGZ paths
183
163
  */
184
- const collectTransitiveWorkspaceDependencies = ({ workspaceMap, initialDependencies, logger }) => {
164
+ const collectTransitiveWorkspaceDependencies = async ({ workspaceMap, initialDependencies, logger }) => {
185
165
  const usedWorkspacePackages = /* @__PURE__ */ new Set();
186
166
  const queue = Array.from(initialDependencies);
187
167
  const resolutions = {};
@@ -196,7 +176,8 @@ const collectTransitiveWorkspaceDependencies = ({ workspaceMap, initialDependenc
196
176
  if (!root) throw new Error("Could not find workspace root");
197
177
  const depsService = new require_services.DepsService(root.location);
198
178
  depsService.__setLogger(logger);
199
- const sanitizedName = (0, _sindresorhus_slugify.default)(pkgName);
179
+ const slugify = (await import("@sindresorhus/slugify")).default;
180
+ const sanitizedName = slugify(pkgName);
200
181
  resolutions[pkgName] = depsService.getWorkspaceDependencyPath({
201
182
  pkgName: sanitizedName,
202
183
  version: dep.version
@@ -219,6 +200,7 @@ const packWorkspaceDependencies = async ({ workspaceMap, usedWorkspacePackages,
219
200
  const depsService = new require_services.DepsService(root.location);
220
201
  depsService.__setLogger(logger);
221
202
  if (usedWorkspacePackages.size > 0) {
203
+ const slugify = (await import("@sindresorhus/slugify")).default;
222
204
  const workspaceDirPath = (0, path.join)(bundleOutputDir, "workspace-module");
223
205
  await (0, fs_extra.ensureDir)(workspaceDirPath);
224
206
  logger.info("Packaging workspace dependencies", { count: usedWorkspacePackages.size });
@@ -229,7 +211,7 @@ const packWorkspaceDependencies = async ({ workspaceMap, usedWorkspacePackages,
229
211
  logger.info(`Packaging batch ${Math.floor(i / batchSize) + 1}/${Math.ceil(packages.length / batchSize)}: ${batch.join(", ")}`);
230
212
  await Promise.all(batch.map(async (pkgName) => {
231
213
  const dep = workspaceMap.get(pkgName);
232
- const sanitizedName = (0, _sindresorhus_slugify.default)(pkgName);
214
+ const sanitizedName = slugify(pkgName);
233
215
  if (!dep) return;
234
216
  await depsService.pack({
235
217
  dir: dep.location,
@@ -393,7 +375,7 @@ function getInputPlugins$1({ entry, isVirtualFile }, mastraEntry, { sourcemapEna
393
375
  * Analyzes both static imports and dynamic imports while filtering out Node.js built-ins and ignored dependencies.
394
376
  * Identifies workspace packages and resolves package root paths for proper bundling optimization.
395
377
  */
396
- async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, shouldCheckTransitiveDependencies }) {
378
+ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, mastraEntry, shouldCheckTransitiveDependencies, analyzeCache, activeEntries }) {
397
379
  const depsToOptimize = /* @__PURE__ */ new Map();
398
380
  if (!output.facadeModuleId) throw new Error("Something went wrong, we could not find the package name of the entry file. Please open an issue.");
399
381
  let entryRootPath = projectRoot;
@@ -421,47 +403,55 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
421
403
  packageSpec
422
404
  });
423
405
  }
424
- const processedWorkspaceDeps = /* @__PURE__ */ new Set();
406
+ const processedWorkspaceEntries = /* @__PURE__ */ new Set();
425
407
  /**
426
408
  * Recursively discovers transitive workspace dependencies from package manifests.
427
409
  */
428
- function checkTransitiveDependencies(maxDepth = 10, currentDepth = 0) {
429
- if (currentDepth >= maxDepth) {
430
- logger.warn("Maximum dependency depth reached while checking transitive dependencies.");
431
- return;
432
- }
410
+ async function checkTransitiveDependencies() {
433
411
  const depsSnapshot = new Map(depsToOptimize);
434
- let hasAddedDeps = false;
435
412
  for (const [dep, meta] of depsSnapshot) {
436
- const pkgName = require_utils.getPackageName(dep);
437
- if (!pkgName || !meta.isWorkspace || processedWorkspaceDeps.has(pkgName)) continue;
438
- processedWorkspaceDeps.add(pkgName);
439
- const workspaceInfo = workspaceMap.get(pkgName);
440
- if (!workspaceInfo?.dependencies) continue;
441
- for (const [innerDep, _innerDepVersion] of Object.entries(workspaceInfo.dependencies)) {
442
- const innerWorkspaceInfo = workspaceMap.get(innerDep);
443
- if (!innerWorkspaceInfo) continue;
444
- if (!hasRootExport(innerWorkspaceInfo.exports)) continue;
413
+ if (!require_utils.getPackageName(dep) || !meta.isWorkspace) continue;
414
+ const importerPath = (0, url.pathToFileURL)(output.facadeModuleId.startsWith("\0virtual:") ? mastraEntry || projectRoot : output.facadeModuleId).href;
415
+ const resolvedPath = (0, local_pkg.resolveModule)(dep, { paths: [importerPath] });
416
+ if (!resolvedPath) {
417
+ logger.warn("Could not resolve path for workspace dependency", { dep });
418
+ continue;
419
+ }
420
+ const resolvedEntry = require_utils.slash(resolvedPath);
421
+ if (processedWorkspaceEntries.has(resolvedEntry) || activeEntries.has(resolvedEntry)) continue;
422
+ processedWorkspaceEntries.add(resolvedEntry);
423
+ const analysis = await analyzeEntry({
424
+ entry: resolvedPath,
425
+ isVirtualFile: false
426
+ }, mastraEntry, {
427
+ workspaceMap,
428
+ projectRoot,
429
+ logger,
430
+ sourcemapEnabled: false,
431
+ shouldCheckTransitiveDependencies: true,
432
+ analyzeCache,
433
+ activeEntries
434
+ });
435
+ if (!analysis?.dependencies) continue;
436
+ for (const [innerDep, innerMeta] of analysis.dependencies) {
437
+ if (!innerMeta.isWorkspace) continue;
445
438
  const existingMeta = depsToOptimize.get(innerDep);
446
439
  if (existingMeta) {
447
440
  depsToOptimize.set(innerDep, {
448
441
  ...existingMeta,
449
- exports: existingMeta.exports.includes("*") ? existingMeta.exports : [...existingMeta.exports, "*"]
442
+ exports: [.../* @__PURE__ */ new Set([...existingMeta.exports, ...innerMeta.exports])]
450
443
  });
451
444
  continue;
452
- }
453
- depsToOptimize.set(innerDep, {
454
- exports: ["*"],
455
- rootPath: require_utils.slash(innerWorkspaceInfo.location),
445
+ } else depsToOptimize.set(innerDep, {
446
+ exports: innerMeta.exports,
447
+ rootPath: require_utils.slash(innerMeta.rootPath || ""),
456
448
  isWorkspace: true,
457
- version: innerWorkspaceInfo.version
449
+ version: innerMeta.version
458
450
  });
459
- hasAddedDeps = true;
460
451
  }
461
452
  }
462
- if (hasAddedDeps) checkTransitiveDependencies(maxDepth, currentDepth + 1);
463
453
  }
464
- if (shouldCheckTransitiveDependencies) checkTransitiveDependencies();
454
+ if (shouldCheckTransitiveDependencies) await checkTransitiveDependencies();
465
455
  const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
466
456
  if (dynamicImports.length) {
467
457
  for (const dynamicImport of dynamicImports) if (!depsToOptimize.has(dynamicImport) && require_utils.isBareModuleSpecifier(dynamicImport)) {
@@ -486,37 +476,54 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
486
476
  }
487
477
  return depsToOptimize;
488
478
  }
489
- async function analyzeEntry({ entry, isVirtualFile }, mastraEntry, { logger, sourcemapEnabled, workspaceMap, projectRoot, shouldCheckTransitiveDependencies = false, analyzeCache }) {
490
- const cacheKey = isVirtualFile ? void 0 : require_utils.slash(entry);
491
- if (cacheKey && analyzeCache?.has(cacheKey)) return analyzeCache.get(cacheKey);
492
- const optimizerBundler = await (0, rollup.rollup)({
493
- logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
494
- input: isVirtualFile ? "#entry" : entry,
495
- treeshake: false,
496
- preserveSymlinks: true,
497
- plugins: getInputPlugins$1({
498
- entry,
499
- isVirtualFile
500
- }, mastraEntry, { sourcemapEnabled }),
501
- external: DEPS_TO_IGNORE
502
- });
503
- const { output } = await optimizerBundler.generate({
504
- format: "esm",
505
- inlineDynamicImports: true
506
- });
507
- await optimizerBundler.close();
508
- const result = {
509
- dependencies: await captureDependenciesToOptimize(output[0], workspaceMap, projectRoot, {
510
- logger,
511
- shouldCheckTransitiveDependencies
512
- }),
513
- output: {
514
- code: output[0].code,
515
- map: output[0].map
516
- }
517
- };
518
- if (cacheKey && analyzeCache) analyzeCache.set(cacheKey, result);
519
- return result;
479
+ async function analyzeEntry({ entry, isVirtualFile }, mastraEntry, { logger, sourcemapEnabled, workspaceMap, projectRoot, shouldCheckTransitiveDependencies = false, analyzeCache, activeEntries: providedActiveEntries }) {
480
+ const resolvedEntry = isVirtualFile ? void 0 : require_utils.slash(entry);
481
+ const effectiveAnalyzeCache = analyzeCache ?? /* @__PURE__ */ new Map();
482
+ const cacheKey = resolvedEntry ? `${resolvedEntry}:${shouldCheckTransitiveDependencies ? "transitive" : "direct"}` : void 0;
483
+ if (cacheKey && effectiveAnalyzeCache.has(cacheKey)) return effectiveAnalyzeCache.get(cacheKey);
484
+ const activeEntries = providedActiveEntries ?? /* @__PURE__ */ new Set();
485
+ const shouldTrackEntry = Boolean(resolvedEntry && !activeEntries.has(resolvedEntry));
486
+ if (resolvedEntry && shouldTrackEntry) activeEntries.add(resolvedEntry);
487
+ try {
488
+ const optimizerBundler = await (0, rollup.rollup)({
489
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
490
+ input: isVirtualFile ? "#entry" : entry,
491
+ treeshake: false,
492
+ preserveSymlinks: true,
493
+ plugins: getInputPlugins$1({
494
+ entry,
495
+ isVirtualFile
496
+ }, mastraEntry, { sourcemapEnabled }),
497
+ external: DEPS_TO_IGNORE
498
+ });
499
+ const { output } = await (async () => {
500
+ try {
501
+ return await optimizerBundler.generate({
502
+ format: "esm",
503
+ inlineDynamicImports: true
504
+ });
505
+ } finally {
506
+ await optimizerBundler.close();
507
+ }
508
+ })();
509
+ const result = {
510
+ dependencies: await captureDependenciesToOptimize(output[0], workspaceMap, projectRoot, {
511
+ logger,
512
+ mastraEntry,
513
+ shouldCheckTransitiveDependencies,
514
+ analyzeCache: effectiveAnalyzeCache,
515
+ activeEntries
516
+ }),
517
+ output: {
518
+ code: output[0].code,
519
+ map: output[0].map
520
+ }
521
+ };
522
+ if (cacheKey) effectiveAnalyzeCache.set(cacheKey, result);
523
+ return result;
524
+ } finally {
525
+ if (resolvedEntry && shouldTrackEntry) activeEntries.delete(resolvedEntry);
526
+ }
520
527
  }
521
528
  //#endregion
522
529
  //#region src/build/plugins/hono-alias.ts
@@ -641,7 +648,7 @@ function createVirtualDependencies(depsToOptimize, { projectRoot, workspaceRoot,
641
648
  * Configures and returns Rollup plugins for bundling external dependencies.
642
649
  * Sets up virtual modules, TypeScript compilation, CommonJS transformation, and workspace resolution.
643
650
  */
644
- async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, rootDir, externals, platform }) {
651
+ async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, projectRoot, rootDir, externals, platform }) {
645
652
  const transpilePackagesMap = /* @__PURE__ */ new Map();
646
653
  for (const pkg of transpilePackages) {
647
654
  const dir = await require_bundler.getPackageRootPath(pkg);
@@ -653,7 +660,7 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
653
660
  acc[`#virtual-${dep}`] = virtualDep.virtual;
654
661
  return acc;
655
662
  }, {})),
656
- require_bundler.tsConfigPaths(),
663
+ require_bundler.tsConfigPaths({ cwd: projectRoot }),
657
664
  require_bundler.protocolExternalResolver(),
658
665
  require_bundler.subpathExternalsResolver(externals),
659
666
  transpilePackagesMap.size ? require_bundler.esbuild({
@@ -688,7 +695,11 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
688
695
  transformMixedEsModules: true,
689
696
  ignoreTryCatch: false
690
697
  }),
691
- bundlerOptions.noBundling ? null : (0, _rollup_plugin_node_resolve.default)(require_utils.getNodeResolveOptions(platform)),
698
+ bundlerOptions.noBundling ? null : (0, _rollup_plugin_node_resolve.default)({
699
+ ...require_utils.getNodeResolveOptions(platform),
700
+ rootDir: projectRoot,
701
+ modulePaths: [path.join(rootDir, "node_modules")]
702
+ }),
692
703
  bundlerOptions.noBundling ? require_bundler.esmShim() : null,
693
704
  aliasHono(),
694
705
  (0, _rollup_plugin_json.default)(),
@@ -701,7 +712,7 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
701
712
  async handler(id, importer) {
702
713
  if (!importer) return null;
703
714
  if (!id.endsWith(".node")) return null;
704
- const packageName = (await (0, local_pkg.getPackageInfo)(importer))?.packageJson?.name || id;
715
+ const packageName = (await require_bundler.getPackageInfo(importer))?.packageJson?.name || id;
705
716
  throw new _mastra_core_error.MastraBaseError({
706
717
  id: "DEPLOYER_BUNDLE_EXTERNALS_MISSING_NATIVE_BUILD",
707
718
  domain: _mastra_core_error.ErrorDomain.DEPLOYER,
@@ -729,7 +740,7 @@ export const mastra = new Mastra({
729
740
  * Executes the Rollup build process for virtual dependencies using configured plugins.
730
741
  * Bundles all virtual dependency modules into optimized ESM files with proper external handling.
731
742
  */
732
- async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, rootDir, outputDir, bundlerOptions, platform }) {
743
+ async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, projectRoot, rootDir, outputDir, bundlerOptions, platform }) {
733
744
  /**
734
745
  * If there are no virtual dependencies to bundle, return an empty array to avoid Rollup errors.
735
746
  */
@@ -739,6 +750,7 @@ async function buildExternalDependencies(virtualDependencies, { externals, packa
739
750
  transpilePackages: packagesToTranspile,
740
751
  workspaceMap,
741
752
  bundlerOptions: { noBundling },
753
+ projectRoot,
742
754
  rootDir,
743
755
  externals,
744
756
  platform
@@ -861,6 +873,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
861
873
  externals: mergedExternals,
862
874
  packagesToTranspile,
863
875
  workspaceMap,
876
+ projectRoot,
864
877
  rootDir: workspaceRoot || projectRoot,
865
878
  outputDir,
866
879
  bundlerOptions: {
@@ -912,13 +925,13 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
912
925
  //#endregion
913
926
  //#region src/build/analyze/externals.ts
914
927
  function normalizeExternals(externals) {
915
- const userExternals = Array.isArray(externals) ? externals : [];
928
+ const explicitExternals = Array.isArray(externals) ? externals : [];
916
929
  return {
917
930
  externalsPreset: externals === true,
918
931
  mergedExternals: [...new Set([
919
932
  ...GLOBAL_EXTERNALS,
920
933
  ...DEPRECATED_EXTERNALS,
921
- ...userExternals
934
+ ...explicitExternals
922
935
  ].filter(Boolean))]
923
936
  };
924
937
  }
@@ -1260,6 +1273,7 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
1260
1273
  logger.info("Analyzing dependencies...");
1261
1274
  const allUsedExternals = /* @__PURE__ */ new Map();
1262
1275
  const analyzeCache = /* @__PURE__ */ new Map();
1276
+ const activeAnalyzeEntries = /* @__PURE__ */ new Set();
1263
1277
  for (const entry of entries) {
1264
1278
  const analyzeResult = await analyzeEntry({
1265
1279
  entry,
@@ -1270,7 +1284,8 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
1270
1284
  workspaceMap,
1271
1285
  projectRoot,
1272
1286
  shouldCheckTransitiveDependencies: true,
1273
- analyzeCache
1287
+ analyzeCache,
1288
+ activeEntries: activeAnalyzeEntries
1274
1289
  });
1275
1290
  (0, _babel_core.transformSync)(analyzeResult.output.code, {
1276
1291
  filename: "pino-detection.js",
@@ -1435,4 +1450,4 @@ Object.defineProperty(exports, "packWorkspaceDependencies", {
1435
1450
  }
1436
1451
  });
1437
1452
 
1438
- //# sourceMappingURL=analyze-hp4aHpms.cjs.map
1453
+ //# sourceMappingURL=analyze-BC22OIkc.cjs.map