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

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 (121) 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-ClD1cvPT.cjs} +150 -99
  4. package/dist/analyze-ClD1cvPT.cjs.map +1 -0
  5. package/dist/{analyze-B5HY26Tt.js → analyze-DEk6PGTI.js} +148 -96
  6. package/dist/analyze-DEk6PGTI.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 +8 -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 +2 -1
  16. package/dist/build/analyze.d.ts.map +1 -1
  17. package/dist/build/analyze.js +1 -1
  18. package/dist/build/bundler.cjs +2 -1
  19. package/dist/build/bundler.d.ts +10 -0
  20. package/dist/build/bundler.d.ts.map +1 -1
  21. package/dist/build/bundler.js +2 -2
  22. package/dist/build/index.cjs +6 -6
  23. package/dist/build/index.js +6 -6
  24. package/dist/build/package-info.d.ts +4 -0
  25. package/dist/build/package-info.d.ts.map +1 -1
  26. package/dist/build/plugins/subpath-externals-resolver.d.ts +2 -1
  27. package/dist/build/plugins/subpath-externals-resolver.d.ts.map +1 -1
  28. package/dist/build/plugins/tsconfig-paths.d.ts +2 -1
  29. package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
  30. package/dist/build/watcher.d.ts.map +1 -1
  31. package/dist/{build-Dit9VFE2.cjs → build-DJMEiMA1.cjs} +8 -7
  32. package/dist/build-DJMEiMA1.cjs.map +1 -0
  33. package/dist/{build-Boe3fe3L.js → build-JNlRQOvG.js} +8 -7
  34. package/dist/build-JNlRQOvG.js.map +1 -0
  35. package/dist/bundler/index.cjs +29 -62
  36. package/dist/bundler/index.cjs.map +1 -1
  37. package/dist/bundler/index.d.ts +1 -11
  38. package/dist/bundler/index.d.ts.map +1 -1
  39. package/dist/bundler/index.js +30 -63
  40. package/dist/bundler/index.js.map +1 -1
  41. package/dist/bundler/workspaceDependencies.d.ts +1 -1
  42. package/dist/bundler/workspaceDependencies.d.ts.map +1 -1
  43. package/dist/{bundler-CzQiVHzN.js → bundler-CC0klr1q.js} +63 -13
  44. package/dist/bundler-CC0klr1q.js.map +1 -0
  45. package/dist/{bundler-BKf2S2r_.cjs → bundler-CjoP35xh.cjs} +74 -11
  46. package/dist/bundler-CjoP35xh.cjs.map +1 -0
  47. package/dist/{bundlerOptions-I2E5y2Wp.cjs → bundlerOptions-09fXosF4.cjs} +2 -2
  48. package/dist/{bundlerOptions-I2E5y2Wp.cjs.map → bundlerOptions-09fXosF4.cjs.map} +1 -1
  49. package/dist/{bundlerOptions-BSySFLb3.js → bundlerOptions-BaAR_H3U.js} +2 -2
  50. package/dist/{bundlerOptions-BSySFLb3.js.map → bundlerOptions-BaAR_H3U.js.map} +1 -1
  51. package/dist/core-D3wM1JKp.js +1159 -0
  52. package/dist/core-D3wM1JKp.js.map +1 -0
  53. package/dist/core-QL_X0T4Y.cjs +1159 -0
  54. package/dist/core-QL_X0T4Y.cjs.map +1 -0
  55. package/dist/docs/SKILL.md +1 -1
  56. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  57. package/dist/docs/references/docs-deployment-monorepo.md +2 -2
  58. package/dist/{effect-QlVUlMFu-tf02PTZR.cjs → effect-QlVUlMFu-B2nZ842E.cjs} +3 -3
  59. package/dist/{effect-QlVUlMFu-tf02PTZR.cjs.map → effect-QlVUlMFu-B2nZ842E.cjs.map} +1 -1
  60. package/dist/{effect-QlVUlMFu-BN-VJnMF.js → effect-QlVUlMFu-DbWuPaWV.js} +3 -3
  61. package/dist/{effect-QlVUlMFu-BN-VJnMF.js.map → effect-QlVUlMFu-DbWuPaWV.js.map} +1 -1
  62. package/dist/{esm-DZ1Siz1C.cjs → esm-Ai6osZ1a.cjs} +61 -50
  63. package/dist/esm-Ai6osZ1a.cjs.map +1 -0
  64. package/dist/{esm-B51vJPGv.js → esm-D-wYOO-S.js} +61 -50
  65. package/dist/esm-D-wYOO-S.js.map +1 -0
  66. package/dist/{index-CLddUTqr-eO-ae7Sx.js → index-CLddUTqr-BXqo9et4.js} +8 -8
  67. package/dist/{index-CLddUTqr-eO-ae7Sx.js.map → index-CLddUTqr-BXqo9et4.js.map} +1 -1
  68. package/dist/{index-CLddUTqr-DS5tJ3WV.cjs → index-CLddUTqr-DsGkVS-W.cjs} +8 -8
  69. package/dist/{index-CLddUTqr-DS5tJ3WV.cjs.map → index-CLddUTqr-DsGkVS-W.cjs.map} +1 -1
  70. package/dist/index.cjs +3 -3
  71. package/dist/index.js +3 -3
  72. package/dist/server/index.cjs +21 -19
  73. package/dist/server/index.cjs.map +1 -1
  74. package/dist/server/index.d.ts +2 -2
  75. package/dist/server/index.js +22 -20
  76. package/dist/server/index.js.map +1 -1
  77. package/dist/services/deps.d.ts +1 -1
  78. package/dist/services/deps.d.ts.map +1 -1
  79. package/dist/services/index.cjs +1 -1
  80. package/dist/services/index.js +1 -1
  81. package/dist/{services-BLvNG7v7.cjs → services-Beob47UW.cjs} +42 -23
  82. package/dist/services-Beob47UW.cjs.map +1 -0
  83. package/dist/{services-B9KRKBT-.js → services-Lm6PRS4D.js} +42 -23
  84. package/dist/services-Lm6PRS4D.js.map +1 -0
  85. package/dist/{sury-CWZTCd75-YUPbTtKO.cjs → sury-CWZTCd75-ChXu4j-p.cjs} +3 -3
  86. package/dist/{sury-CWZTCd75-YUPbTtKO.cjs.map → sury-CWZTCd75-ChXu4j-p.cjs.map} +1 -1
  87. package/dist/{sury-CWZTCd75-ClSNrMWF.js → sury-CWZTCd75-OKz7uWLi.js} +3 -3
  88. package/dist/{sury-CWZTCd75-ClSNrMWF.js.map → sury-CWZTCd75-OKz7uWLi.js.map} +1 -1
  89. package/dist/{typebox-Dei93FPO-CVSJ3SAf.js → typebox-Dei93FPO-C5ACKU09.js} +2 -2
  90. package/dist/{typebox-Dei93FPO-CVSJ3SAf.js.map → typebox-Dei93FPO-C5ACKU09.js.map} +1 -1
  91. package/dist/{typebox-Dei93FPO-BTBshlGz.cjs → typebox-Dei93FPO-KTtPU745.cjs} +2 -2
  92. package/dist/{typebox-Dei93FPO-BTBshlGz.cjs.map → typebox-Dei93FPO-KTtPU745.cjs.map} +1 -1
  93. package/dist/{utils-DYi43Kp4.js → utils-Bl3Lm7SI.js} +1 -2
  94. package/dist/{utils-DYi43Kp4.js.map → utils-Bl3Lm7SI.js.map} +1 -1
  95. package/dist/{utils-7WDNT3Ca.cjs → utils-Bsr_sEcH.cjs} +2 -2
  96. package/dist/{utils-7WDNT3Ca.cjs.map → utils-Bsr_sEcH.cjs.map} +1 -1
  97. package/dist/{valibot--1zFm7rT-Dn5WqdyK.cjs → valibot--1zFm7rT-BeX3W1HK.cjs} +3 -3
  98. package/dist/{valibot--1zFm7rT-Dn5WqdyK.cjs.map → valibot--1zFm7rT-BeX3W1HK.cjs.map} +1 -1
  99. package/dist/{valibot--1zFm7rT-BxcEC3Pu.js → valibot--1zFm7rT-BuVb-6oJ.js} +3 -3
  100. package/dist/{valibot--1zFm7rT-BxcEC3Pu.js.map → valibot--1zFm7rT-BuVb-6oJ.js.map} +1 -1
  101. package/dist/validator/custom-resolver.cjs +1 -1
  102. package/dist/validator/custom-resolver.js +1 -1
  103. package/dist/{zod-Bwrt9trS-Bd40XYOT.js → zod-Bwrt9trS-D5b1oyiT.js} +5 -5
  104. package/dist/{zod-Bwrt9trS-Bd40XYOT.js.map → zod-Bwrt9trS-D5b1oyiT.js.map} +1 -1
  105. package/dist/{zod-Bwrt9trS-Bi11nE9Q.cjs → zod-Bwrt9trS-DGQs9DWc.cjs} +5 -5
  106. package/dist/{zod-Bwrt9trS-Bi11nE9Q.cjs.map → zod-Bwrt9trS-DGQs9DWc.cjs.map} +1 -1
  107. package/package.json +15 -14
  108. package/dist/analyze-B5HY26Tt.js.map +0 -1
  109. package/dist/analyze-hp4aHpms.cjs.map +0 -1
  110. package/dist/build-Boe3fe3L.js.map +0 -1
  111. package/dist/build-Dit9VFE2.cjs.map +0 -1
  112. package/dist/bundler-BKf2S2r_.cjs.map +0 -1
  113. package/dist/bundler-CzQiVHzN.js.map +0 -1
  114. package/dist/core-D0wEgdn3.cjs +0 -790
  115. package/dist/core-D0wEgdn3.cjs.map +0 -1
  116. package/dist/core-DF65PJXc.js +0 -790
  117. package/dist/core-DF65PJXc.js.map +0 -1
  118. package/dist/esm-B51vJPGv.js.map +0 -1
  119. package/dist/esm-DZ1Siz1C.cjs.map +0 -1
  120. package/dist/services-B9KRKBT-.js.map +0 -1
  121. 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-CjoP35xh.cjs");
6
5
  let fs = require("fs");
7
6
  let fs_promises = require("fs/promises");
8
7
  let path = require("path");
@@ -13,23 +12,22 @@ _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
- let path_posix = require("path/posix");
31
28
  let resolve_exports = require("resolve.exports");
32
29
  resolve_exports = require_rolldown_runtime.__toESM(resolve_exports, 1);
30
+ let path_posix = require("path/posix");
33
31
  //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/stacktrace-parser/0.1.11/63406bc765474556691ebd1b24eaa0c5b032f058a26bbaff13797a2780d98220/node_modules/stacktrace-parser/dist/stack-trace-parser.cjs.js
34
32
  var require_stack_trace_parser_cjs = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((exports) => {
35
33
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,
@@ -358,11 +340,26 @@ const DEPRECATED_EXTERNALS = [
358
340
  ];
359
341
  //#endregion
360
342
  //#region src/build/analyze/analyzeEntry.ts
343
+ function analysisExternals({ workspaceMap, externals, externalsPreset }) {
344
+ return {
345
+ name: "analysis-externals",
346
+ resolveId(source) {
347
+ if (!require_utils.isBareModuleSpecifier(source)) return null;
348
+ const packageName = require_utils.getPackageName(source);
349
+ if (packageName && workspaceMap.has(packageName)) return null;
350
+ if (externalsPreset || externals.some((external) => require_utils.isDependencyPartOfPackage(source, external))) return {
351
+ id: source,
352
+ external: true
353
+ };
354
+ return null;
355
+ }
356
+ };
357
+ }
361
358
  /**
362
359
  * Configures and returns the Rollup plugins needed for analyzing entry files.
363
360
  * Sets up module resolution, transpilation, and custom alias handling for Mastra-specific imports.
364
361
  */
365
- function getInputPlugins$1({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }) {
362
+ function getInputPlugins$1({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled, env, workspaceMap, externals, externalsPreset }) {
366
363
  let virtualPlugin = null;
367
364
  if (isVirtualFile) {
368
365
  virtualPlugin = (0, _rollup_plugin_virtual.default)({ "#entry": entry });
@@ -375,8 +372,13 @@ function getInputPlugins$1({ entry, isVirtualFile }, mastraEntry, { sourcemapEna
375
372
  require_bundler.mastraInternalAliasPlugin(mastraEntry),
376
373
  require_bundler.mastraToolsAliasPlugin(),
377
374
  require_bundler.tsConfigPaths(),
375
+ analysisExternals({
376
+ workspaceMap,
377
+ externals,
378
+ externalsPreset
379
+ }),
378
380
  (0, _rollup_plugin_json.default)(),
379
- require_bundler.esbuild(),
381
+ require_bundler.esbuild({ define: env }),
380
382
  (0, _rollup_plugin_commonjs.default)({
381
383
  strictRequires: "debug",
382
384
  ignoreTryCatch: false,
@@ -393,7 +395,7 @@ function getInputPlugins$1({ entry, isVirtualFile }, mastraEntry, { sourcemapEna
393
395
  * Analyzes both static imports and dynamic imports while filtering out Node.js built-ins and ignored dependencies.
394
396
  * Identifies workspace packages and resolves package root paths for proper bundling optimization.
395
397
  */
396
- async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, shouldCheckTransitiveDependencies }) {
398
+ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, mastraEntry, shouldCheckTransitiveDependencies, env, analyzeCache, activeEntries, externals, externalsPreset }) {
397
399
  const depsToOptimize = /* @__PURE__ */ new Map();
398
400
  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
401
  let entryRootPath = projectRoot;
@@ -421,47 +423,58 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
421
423
  packageSpec
422
424
  });
423
425
  }
424
- const processedWorkspaceDeps = /* @__PURE__ */ new Set();
426
+ const processedWorkspaceEntries = /* @__PURE__ */ new Set();
425
427
  /**
426
428
  * Recursively discovers transitive workspace dependencies from package manifests.
427
429
  */
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
- }
430
+ async function checkTransitiveDependencies() {
433
431
  const depsSnapshot = new Map(depsToOptimize);
434
- let hasAddedDeps = false;
435
432
  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;
433
+ if (!require_utils.getPackageName(dep) || !meta.isWorkspace) continue;
434
+ const importerPath = (0, url.pathToFileURL)(output.facadeModuleId.startsWith("\0virtual:") ? mastraEntry || projectRoot : output.facadeModuleId).href;
435
+ const resolvedPath = (0, local_pkg.resolveModule)(dep, { paths: [importerPath] });
436
+ if (!resolvedPath) {
437
+ logger.warn("Could not resolve path for workspace dependency", { dep });
438
+ continue;
439
+ }
440
+ const resolvedEntry = require_utils.slash(resolvedPath);
441
+ if (processedWorkspaceEntries.has(resolvedEntry) || activeEntries.has(resolvedEntry)) continue;
442
+ processedWorkspaceEntries.add(resolvedEntry);
443
+ const analysis = await analyzeEntry({
444
+ entry: resolvedPath,
445
+ isVirtualFile: false
446
+ }, mastraEntry, {
447
+ workspaceMap,
448
+ projectRoot,
449
+ logger,
450
+ sourcemapEnabled: false,
451
+ env,
452
+ shouldCheckTransitiveDependencies: true,
453
+ analyzeCache,
454
+ activeEntries,
455
+ externals,
456
+ externalsPreset
457
+ });
458
+ if (!analysis?.dependencies) continue;
459
+ for (const [innerDep, innerMeta] of analysis.dependencies) {
460
+ if (!innerMeta.isWorkspace) continue;
445
461
  const existingMeta = depsToOptimize.get(innerDep);
446
462
  if (existingMeta) {
447
463
  depsToOptimize.set(innerDep, {
448
464
  ...existingMeta,
449
- exports: existingMeta.exports.includes("*") ? existingMeta.exports : [...existingMeta.exports, "*"]
465
+ exports: [.../* @__PURE__ */ new Set([...existingMeta.exports, ...innerMeta.exports])]
450
466
  });
451
467
  continue;
452
- }
453
- depsToOptimize.set(innerDep, {
454
- exports: ["*"],
455
- rootPath: require_utils.slash(innerWorkspaceInfo.location),
468
+ } else depsToOptimize.set(innerDep, {
469
+ exports: innerMeta.exports,
470
+ rootPath: require_utils.slash(innerMeta.rootPath || ""),
456
471
  isWorkspace: true,
457
- version: innerWorkspaceInfo.version
472
+ version: innerMeta.version
458
473
  });
459
- hasAddedDeps = true;
460
474
  }
461
475
  }
462
- if (hasAddedDeps) checkTransitiveDependencies(maxDepth, currentDepth + 1);
463
476
  }
464
- if (shouldCheckTransitiveDependencies) checkTransitiveDependencies();
477
+ if (shouldCheckTransitiveDependencies) await checkTransitiveDependencies();
465
478
  const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
466
479
  if (dynamicImports.length) {
467
480
  for (const dynamicImport of dynamicImports) if (!depsToOptimize.has(dynamicImport) && require_utils.isBareModuleSpecifier(dynamicImport)) {
@@ -486,37 +499,64 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
486
499
  }
487
500
  return depsToOptimize;
488
501
  }
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;
502
+ async function analyzeEntry({ entry, isVirtualFile }, mastraEntry, { logger, sourcemapEnabled, workspaceMap, projectRoot, env = { "process.env.NODE_ENV": JSON.stringify("production") }, shouldCheckTransitiveDependencies = false, analyzeCache, activeEntries: providedActiveEntries, externals = [], externalsPreset = false }) {
503
+ const resolvedEntry = isVirtualFile ? void 0 : require_utils.slash(entry);
504
+ const effectiveAnalyzeCache = analyzeCache ?? /* @__PURE__ */ new Map();
505
+ const externalsCacheKey = JSON.stringify([externalsPreset, [...externals].sort()]);
506
+ const cacheKey = resolvedEntry ? `${resolvedEntry}:${shouldCheckTransitiveDependencies ? "transitive" : "direct"}:${externalsCacheKey}` : void 0;
507
+ if (cacheKey && effectiveAnalyzeCache.has(cacheKey)) return effectiveAnalyzeCache.get(cacheKey);
508
+ const activeEntries = providedActiveEntries ?? /* @__PURE__ */ new Set();
509
+ const shouldTrackEntry = Boolean(resolvedEntry && !activeEntries.has(resolvedEntry));
510
+ if (resolvedEntry && shouldTrackEntry) activeEntries.add(resolvedEntry);
511
+ try {
512
+ const optimizerBundler = await (0, rollup.rollup)({
513
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
514
+ input: isVirtualFile ? "#entry" : entry,
515
+ treeshake: false,
516
+ preserveSymlinks: true,
517
+ plugins: getInputPlugins$1({
518
+ entry,
519
+ isVirtualFile
520
+ }, mastraEntry, {
521
+ sourcemapEnabled,
522
+ env,
523
+ workspaceMap,
524
+ externals,
525
+ externalsPreset
526
+ }),
527
+ external: (id) => DEPS_TO_IGNORE.some((dep) => require_utils.isDependencyPartOfPackage(id, dep))
528
+ });
529
+ const { output } = await (async () => {
530
+ try {
531
+ return await optimizerBundler.generate({
532
+ format: "esm",
533
+ inlineDynamicImports: true
534
+ });
535
+ } finally {
536
+ await optimizerBundler.close();
537
+ }
538
+ })();
539
+ const result = {
540
+ dependencies: await captureDependenciesToOptimize(output[0], workspaceMap, projectRoot, {
541
+ logger,
542
+ mastraEntry,
543
+ shouldCheckTransitiveDependencies,
544
+ env,
545
+ analyzeCache: effectiveAnalyzeCache,
546
+ activeEntries,
547
+ externals,
548
+ externalsPreset
549
+ }),
550
+ output: {
551
+ code: output[0].code,
552
+ map: output[0].map
553
+ }
554
+ };
555
+ if (cacheKey) effectiveAnalyzeCache.set(cacheKey, result);
556
+ return result;
557
+ } finally {
558
+ if (resolvedEntry && shouldTrackEntry) activeEntries.delete(resolvedEntry);
559
+ }
520
560
  }
521
561
  //#endregion
522
562
  //#region src/build/plugins/hono-alias.ts
@@ -641,7 +681,7 @@ function createVirtualDependencies(depsToOptimize, { projectRoot, workspaceRoot,
641
681
  * Configures and returns Rollup plugins for bundling external dependencies.
642
682
  * Sets up virtual modules, TypeScript compilation, CommonJS transformation, and workspace resolution.
643
683
  */
644
- async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, rootDir, externals, platform }) {
684
+ async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, projectRoot, rootDir, externals, platform }) {
645
685
  const transpilePackagesMap = /* @__PURE__ */ new Map();
646
686
  for (const pkg of transpilePackages) {
647
687
  const dir = await require_bundler.getPackageRootPath(pkg);
@@ -653,9 +693,9 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
653
693
  acc[`#virtual-${dep}`] = virtualDep.virtual;
654
694
  return acc;
655
695
  }, {})),
656
- require_bundler.tsConfigPaths(),
696
+ require_bundler.tsConfigPaths({ cwd: projectRoot }),
657
697
  require_bundler.protocolExternalResolver(),
658
- require_bundler.subpathExternalsResolver(externals),
698
+ require_bundler.subpathExternalsResolver(externals, workspaceMap),
659
699
  transpilePackagesMap.size ? require_bundler.esbuild({
660
700
  format: "esm",
661
701
  include: [...[...transpilePackagesMap.values()].map((p) => {
@@ -688,7 +728,11 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
688
728
  transformMixedEsModules: true,
689
729
  ignoreTryCatch: false
690
730
  }),
691
- bundlerOptions.noBundling ? null : (0, _rollup_plugin_node_resolve.default)(require_utils.getNodeResolveOptions(platform)),
731
+ bundlerOptions.noBundling ? null : (0, _rollup_plugin_node_resolve.default)({
732
+ ...require_utils.getNodeResolveOptions(platform),
733
+ rootDir: projectRoot,
734
+ modulePaths: [path.join(rootDir, "node_modules")]
735
+ }),
692
736
  bundlerOptions.noBundling ? require_bundler.esmShim() : null,
693
737
  aliasHono(),
694
738
  (0, _rollup_plugin_json.default)(),
@@ -701,7 +745,7 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
701
745
  async handler(id, importer) {
702
746
  if (!importer) return null;
703
747
  if (!id.endsWith(".node")) return null;
704
- const packageName = (await (0, local_pkg.getPackageInfo)(importer))?.packageJson?.name || id;
748
+ const packageName = (await require_bundler.getPackageInfo(importer))?.packageJson?.name || id;
705
749
  throw new _mastra_core_error.MastraBaseError({
706
750
  id: "DEPLOYER_BUNDLE_EXTERNALS_MISSING_NATIVE_BUILD",
707
751
  domain: _mastra_core_error.ErrorDomain.DEPLOYER,
@@ -729,7 +773,7 @@ export const mastra = new Mastra({
729
773
  * Executes the Rollup build process for virtual dependencies using configured plugins.
730
774
  * Bundles all virtual dependency modules into optimized ESM files with proper external handling.
731
775
  */
732
- async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, rootDir, outputDir, bundlerOptions, platform }) {
776
+ async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, projectRoot, rootDir, outputDir, bundlerOptions, platform }) {
733
777
  /**
734
778
  * If there are no virtual dependencies to bundle, return an empty array to avoid Rollup errors.
735
779
  */
@@ -739,6 +783,7 @@ async function buildExternalDependencies(virtualDependencies, { externals, packa
739
783
  transpilePackages: packagesToTranspile,
740
784
  workspaceMap,
741
785
  bundlerOptions: { noBundling },
786
+ projectRoot,
742
787
  rootDir,
743
788
  externals,
744
789
  platform
@@ -861,6 +906,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
861
906
  externals: mergedExternals,
862
907
  packagesToTranspile,
863
908
  workspaceMap,
909
+ projectRoot,
864
910
  rootDir: workspaceRoot || projectRoot,
865
911
  outputDir,
866
912
  bundlerOptions: {
@@ -912,13 +958,13 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
912
958
  //#endregion
913
959
  //#region src/build/analyze/externals.ts
914
960
  function normalizeExternals(externals) {
915
- const userExternals = Array.isArray(externals) ? externals : [];
961
+ const explicitExternals = Array.isArray(externals) ? externals : [];
916
962
  return {
917
963
  externalsPreset: externals === true,
918
964
  mergedExternals: [...new Set([
919
965
  ...GLOBAL_EXTERNALS,
920
966
  ...DEPRECATED_EXTERNALS,
921
- ...userExternals
967
+ ...explicitExternals
922
968
  ].filter(Boolean))]
923
969
  };
924
970
  }
@@ -1242,7 +1288,7 @@ async function validateOutput({ output, reverseVirtualReferenceMap, usedExternal
1242
1288
  *
1243
1289
  * This helps identify which dependencies need to be externalized vs bundled.
1244
1290
  */
1245
- async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, platform, isDev = false, bundlerOptions }, logger) {
1291
+ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, platform, isDev = false, bundlerOptions, env = { "process.env.NODE_ENV": JSON.stringify("production") } }, logger) {
1246
1292
  const mastraConfig = await (0, fs_promises.readFile)(mastraEntry, "utf-8");
1247
1293
  const mastraConfigResult = { hasValidConfig: false };
1248
1294
  await (0, _babel_core.transformAsync)(mastraConfig, {
@@ -1260,6 +1306,7 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
1260
1306
  logger.info("Analyzing dependencies...");
1261
1307
  const allUsedExternals = /* @__PURE__ */ new Map();
1262
1308
  const analyzeCache = /* @__PURE__ */ new Map();
1309
+ const activeAnalyzeEntries = /* @__PURE__ */ new Set();
1263
1310
  for (const entry of entries) {
1264
1311
  const analyzeResult = await analyzeEntry({
1265
1312
  entry,
@@ -1269,8 +1316,12 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
1269
1316
  sourcemapEnabled: bundlerOptions?.enableSourcemap ?? false,
1270
1317
  workspaceMap,
1271
1318
  projectRoot,
1319
+ env,
1272
1320
  shouldCheckTransitiveDependencies: true,
1273
- analyzeCache
1321
+ analyzeCache,
1322
+ activeEntries: activeAnalyzeEntries,
1323
+ externals: mergedExternals,
1324
+ externalsPreset
1274
1325
  });
1275
1326
  (0, _babel_core.transformSync)(analyzeResult.output.code, {
1276
1327
  filename: "pino-detection.js",
@@ -1435,4 +1486,4 @@ Object.defineProperty(exports, "packWorkspaceDependencies", {
1435
1486
  }
1436
1487
  });
1437
1488
 
1438
- //# sourceMappingURL=analyze-hp4aHpms.cjs.map
1489
+ //# sourceMappingURL=analyze-ClD1cvPT.cjs.map