@mastra/deployer 0.0.0-bundle-recursion-20251030002519 → 0.0.0-bundle-version-20260121091645

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 (250) hide show
  1. package/CHANGELOG.md +1261 -5
  2. package/dist/arktype-aI7TBD0R-CCZH3EYK.js +8 -0
  3. package/dist/arktype-aI7TBD0R-CCZH3EYK.js.map +1 -0
  4. package/dist/arktype-aI7TBD0R-XHBHUL3T.cjs +10 -0
  5. package/dist/arktype-aI7TBD0R-XHBHUL3T.cjs.map +1 -0
  6. package/dist/build/analyze/analyzeEntry.d.ts +4 -1
  7. package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
  8. package/dist/build/analyze/bundleExternals.d.ts +4 -5
  9. package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
  10. package/dist/build/analyze/constants.d.ts.map +1 -1
  11. package/dist/build/analyze.cjs +2 -2
  12. package/dist/build/analyze.d.ts +6 -6
  13. package/dist/build/analyze.d.ts.map +1 -1
  14. package/dist/build/analyze.js +1 -1
  15. package/dist/build/babel/remove-deployer.d.ts.map +1 -1
  16. package/dist/build/bundler.cjs +3 -3
  17. package/dist/build/bundler.d.ts +3 -1
  18. package/dist/build/bundler.d.ts.map +1 -1
  19. package/dist/build/bundler.js +1 -1
  20. package/dist/build/bundlerOptions.d.ts.map +1 -1
  21. package/dist/build/deployer.d.ts.map +1 -1
  22. package/dist/build/index.cjs +22 -13
  23. package/dist/build/index.d.ts +2 -0
  24. package/dist/build/index.d.ts.map +1 -1
  25. package/dist/build/index.js +5 -4
  26. package/dist/build/package-info.d.ts +9 -0
  27. package/dist/build/package-info.d.ts.map +1 -0
  28. package/dist/build/plugins/esm-shim.d.ts +14 -0
  29. package/dist/build/plugins/esm-shim.d.ts.map +1 -0
  30. package/dist/build/plugins/module-resolve-map.d.ts +3 -0
  31. package/dist/build/plugins/module-resolve-map.d.ts.map +1 -0
  32. package/dist/build/plugins/node-gyp-detector.d.ts +3 -0
  33. package/dist/build/plugins/node-gyp-detector.d.ts.map +1 -0
  34. package/dist/build/plugins/node-modules-extension-resolver.d.ts +7 -0
  35. package/dist/build/plugins/node-modules-extension-resolver.d.ts.map +1 -1
  36. package/dist/build/plugins/remove-all-except.d.ts +10 -0
  37. package/dist/build/plugins/remove-all-except.d.ts.map +1 -0
  38. package/dist/build/plugins/subpath-externals-resolver.d.ts +3 -0
  39. package/dist/build/plugins/subpath-externals-resolver.d.ts.map +1 -0
  40. package/dist/build/plugins/tsconfig-paths.d.ts +8 -0
  41. package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
  42. package/dist/build/serverOptions.d.ts.map +1 -1
  43. package/dist/build/shared/extract-mastra-option.d.ts +4 -8
  44. package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
  45. package/dist/build/types.d.ts +18 -0
  46. package/dist/build/types.d.ts.map +1 -1
  47. package/dist/build/utils.d.ts +36 -4
  48. package/dist/build/utils.d.ts.map +1 -1
  49. package/dist/build/watcher.d.ts +2 -1
  50. package/dist/build/watcher.d.ts.map +1 -1
  51. package/dist/bundler/index.cjs +6 -2
  52. package/dist/bundler/index.d.ts +13 -9
  53. package/dist/bundler/index.d.ts.map +1 -1
  54. package/dist/bundler/index.js +1 -1
  55. package/dist/chunk-2VG357HT.cjs +4 -0
  56. package/dist/chunk-2VG357HT.cjs.map +1 -0
  57. package/dist/chunk-5IFGGF2Q.cjs +112 -0
  58. package/dist/chunk-5IFGGF2Q.cjs.map +1 -0
  59. package/dist/chunk-5TYVF4KJ.cjs +76 -0
  60. package/dist/chunk-5TYVF4KJ.cjs.map +1 -0
  61. package/dist/{chunk-QOMQKAKY.cjs → chunk-6ITQIDNC.cjs} +77 -31
  62. package/dist/chunk-6ITQIDNC.cjs.map +1 -0
  63. package/dist/{chunk-ZIBSZS2J.js → chunk-6VRWO5WR.js} +70 -24
  64. package/dist/chunk-6VRWO5WR.js.map +1 -0
  65. package/dist/{chunk-JCACPNJQ.cjs → chunk-AS55XT3Y.cjs} +886 -365
  66. package/dist/chunk-AS55XT3Y.cjs.map +1 -0
  67. package/dist/chunk-DBXWQ2CA.js +159 -0
  68. package/dist/chunk-DBXWQ2CA.js.map +1 -0
  69. package/dist/{chunk-5QFG6SCM.js → chunk-DPDWM7HQ.js} +2 -2
  70. package/dist/chunk-DPDWM7HQ.js.map +1 -0
  71. package/dist/{chunk-L6Z4LACC.js → chunk-FH3CFNNS.js} +77 -39
  72. package/dist/chunk-FH3CFNNS.js.map +1 -0
  73. package/dist/chunk-G6GFAPPU.js +6 -0
  74. package/dist/chunk-G6GFAPPU.js.map +1 -0
  75. package/dist/{chunk-65RQUN2A.js → chunk-GX3DPJAT.js} +873 -352
  76. package/dist/chunk-GX3DPJAT.js.map +1 -0
  77. package/dist/chunk-HPGDVJAZ.js +3 -0
  78. package/dist/chunk-HPGDVJAZ.js.map +1 -0
  79. package/dist/chunk-JBE6KM7R.cjs +95 -0
  80. package/dist/chunk-JBE6KM7R.cjs.map +1 -0
  81. package/dist/chunk-JRUJ546M.cjs +162 -0
  82. package/dist/chunk-JRUJ546M.cjs.map +1 -0
  83. package/dist/{chunk-3JYRSECU.cjs → chunk-JVBCN3RH.cjs} +4 -4
  84. package/dist/chunk-JVBCN3RH.cjs.map +1 -0
  85. package/dist/chunk-KE4NVPI4.cjs +8 -0
  86. package/dist/chunk-KE4NVPI4.cjs.map +1 -0
  87. package/dist/chunk-MCWU6IKS.js +14 -0
  88. package/dist/chunk-MCWU6IKS.js.map +1 -0
  89. package/dist/chunk-QAOUDKHK.js +67 -0
  90. package/dist/chunk-QAOUDKHK.js.map +1 -0
  91. package/dist/{chunk-HS4XRPI7.cjs → chunk-RZIZWYXY.cjs} +83 -44
  92. package/dist/chunk-RZIZWYXY.cjs.map +1 -0
  93. package/dist/chunk-V4HCIN6G.js +93 -0
  94. package/dist/chunk-V4HCIN6G.js.map +1 -0
  95. package/dist/chunk-ZJA5AK4R.js +88 -0
  96. package/dist/chunk-ZJA5AK4R.js.map +1 -0
  97. package/dist/chunk-ZXQ7DOYU.cjs +16 -0
  98. package/dist/chunk-ZXQ7DOYU.cjs.map +1 -0
  99. package/dist/default-u_dwuiYb-JPNIZQKK.cjs +9 -0
  100. package/dist/default-u_dwuiYb-JPNIZQKK.cjs.map +1 -0
  101. package/dist/default-u_dwuiYb-RK5OD4MY.js +3 -0
  102. package/dist/default-u_dwuiYb-RK5OD4MY.js.map +1 -0
  103. package/dist/deploy/log.d.ts +1 -1
  104. package/dist/deploy/log.d.ts.map +1 -1
  105. package/dist/docs/README.md +32 -0
  106. package/dist/docs/SKILL.md +36 -0
  107. package/dist/docs/SOURCE_MAP.json +27 -0
  108. package/dist/docs/deployer/01-reference.md +93 -0
  109. package/dist/docs/deployment/01-overview.md +64 -0
  110. package/dist/docs/deployment/02-mastra-server.md +129 -0
  111. package/dist/docs/deployment/03-monorepo.md +142 -0
  112. package/dist/docs/deployment/04-cloud-providers.md +17 -0
  113. package/dist/docs/deployment/05-web-framework.md +55 -0
  114. package/dist/docs/deployment/06-workflow-runners.md +11 -0
  115. package/dist/effect-QlVUlMFu-HN3LWZSQ.cjs +17 -0
  116. package/dist/effect-QlVUlMFu-HN3LWZSQ.cjs.map +1 -0
  117. package/dist/effect-QlVUlMFu-XOJ2F4UA.js +15 -0
  118. package/dist/effect-QlVUlMFu-XOJ2F4UA.js.map +1 -0
  119. package/dist/esm-6TGK2CUM.js +1289 -0
  120. package/dist/esm-6TGK2CUM.js.map +1 -0
  121. package/dist/esm-SQKX5ABS.cjs +1336 -0
  122. package/dist/esm-SQKX5ABS.cjs.map +1 -0
  123. package/dist/index.cjs +11 -22
  124. package/dist/index.cjs.map +1 -1
  125. package/dist/index.js +5 -16
  126. package/dist/index.js.map +1 -1
  127. package/dist/server/handlers/health.d.ts +5 -0
  128. package/dist/server/handlers/health.d.ts.map +1 -0
  129. package/dist/server/handlers/restart-active-runs.d.ts +3 -0
  130. package/dist/server/handlers/restart-active-runs.d.ts.map +1 -0
  131. package/dist/server/handlers/utils/query-parsers.d.ts +15 -0
  132. package/dist/server/handlers/utils/query-parsers.d.ts.map +1 -1
  133. package/dist/server/handlers/utils.d.ts +0 -7
  134. package/dist/server/handlers/utils.d.ts.map +1 -1
  135. package/dist/server/index.cjs +2813 -11309
  136. package/dist/server/index.cjs.map +1 -1
  137. package/dist/server/index.d.ts +3 -12
  138. package/dist/server/index.d.ts.map +1 -1
  139. package/dist/server/index.js +2813 -11310
  140. package/dist/server/index.js.map +1 -1
  141. package/dist/server/types.d.ts +1 -1
  142. package/dist/server/types.d.ts.map +1 -1
  143. package/dist/server/welcome.d.ts +1 -1
  144. package/dist/server/welcome.d.ts.map +1 -1
  145. package/dist/services/index.cjs +4 -4
  146. package/dist/services/index.js +1 -1
  147. package/dist/sury-CWZTCd75-KEHKUXG7.cjs +17 -0
  148. package/dist/sury-CWZTCd75-KEHKUXG7.cjs.map +1 -0
  149. package/dist/sury-CWZTCd75-L2D76L25.js +15 -0
  150. package/dist/sury-CWZTCd75-L2D76L25.js.map +1 -0
  151. package/dist/typebox-Dei93FPO-LBLFC3RD.js +8 -0
  152. package/dist/typebox-Dei93FPO-LBLFC3RD.js.map +1 -0
  153. package/dist/typebox-Dei93FPO-RDSW6DFA.cjs +10 -0
  154. package/dist/typebox-Dei93FPO-RDSW6DFA.cjs.map +1 -0
  155. package/dist/valibot--1zFm7rT-NVADAEQI.cjs +17 -0
  156. package/dist/valibot--1zFm7rT-NVADAEQI.cjs.map +1 -0
  157. package/dist/valibot--1zFm7rT-R2UKWLZC.js +15 -0
  158. package/dist/valibot--1zFm7rT-R2UKWLZC.js.map +1 -0
  159. package/dist/valibot-D_HTw1Gn-DSFFOUBW.cjs +45 -0
  160. package/dist/valibot-D_HTw1Gn-DSFFOUBW.cjs.map +1 -0
  161. package/dist/valibot-D_HTw1Gn-KWXWP2TJ.js +43 -0
  162. package/dist/valibot-D_HTw1Gn-KWXWP2TJ.js.map +1 -0
  163. package/dist/validator/custom-resolver.cjs +20 -12
  164. package/dist/validator/custom-resolver.cjs.map +1 -1
  165. package/dist/validator/custom-resolver.d.ts.map +1 -1
  166. package/dist/validator/custom-resolver.js +18 -10
  167. package/dist/validator/custom-resolver.js.map +1 -1
  168. package/dist/validator/validate.d.ts +15 -1
  169. package/dist/validator/validate.d.ts.map +1 -1
  170. package/dist/zod-Bwrt9trS-GCUGPBJX.js +29 -0
  171. package/dist/zod-Bwrt9trS-GCUGPBJX.js.map +1 -0
  172. package/dist/zod-Bwrt9trS-ZZHFZ7YQ.cjs +31 -0
  173. package/dist/zod-Bwrt9trS-ZZHFZ7YQ.cjs.map +1 -0
  174. package/dist/zod-DSgpEGAE-3CMS4FSB.cjs +39 -0
  175. package/dist/zod-DSgpEGAE-3CMS4FSB.cjs.map +1 -0
  176. package/dist/zod-DSgpEGAE-IPE3O2NQ.js +37 -0
  177. package/dist/zod-DSgpEGAE-IPE3O2NQ.js.map +1 -0
  178. package/package.json +30 -30
  179. package/dist/build/babel/get-deployer.d.ts +0 -3
  180. package/dist/build/babel/get-deployer.d.ts.map +0 -1
  181. package/dist/build/babel/remove-all-options-bundler.d.ts +0 -5
  182. package/dist/build/babel/remove-all-options-bundler.d.ts.map +0 -1
  183. package/dist/build/babel/remove-all-options-deployer.d.ts +0 -5
  184. package/dist/build/babel/remove-all-options-deployer.d.ts.map +0 -1
  185. package/dist/build/babel/remove-all-options-server.d.ts +0 -5
  186. package/dist/build/babel/remove-all-options-server.d.ts.map +0 -1
  187. package/dist/chunk-3JYRSECU.cjs.map +0 -1
  188. package/dist/chunk-5QFG6SCM.js.map +0 -1
  189. package/dist/chunk-65RQUN2A.js.map +0 -1
  190. package/dist/chunk-6OU6DT6H.js +0 -168
  191. package/dist/chunk-6OU6DT6H.js.map +0 -1
  192. package/dist/chunk-HS4XRPI7.cjs.map +0 -1
  193. package/dist/chunk-JAY7OZFT.cjs +0 -195
  194. package/dist/chunk-JAY7OZFT.cjs.map +0 -1
  195. package/dist/chunk-JCACPNJQ.cjs.map +0 -1
  196. package/dist/chunk-L6Z4LACC.js.map +0 -1
  197. package/dist/chunk-QOMQKAKY.cjs.map +0 -1
  198. package/dist/chunk-ZIBSZS2J.js.map +0 -1
  199. package/dist/server/handlers/auth/defaults.d.ts +0 -3
  200. package/dist/server/handlers/auth/defaults.d.ts.map +0 -1
  201. package/dist/server/handlers/auth/helpers.d.ts +0 -11
  202. package/dist/server/handlers/auth/helpers.d.ts.map +0 -1
  203. package/dist/server/handlers/auth/index.d.ts +0 -11
  204. package/dist/server/handlers/auth/index.d.ts.map +0 -1
  205. package/dist/server/handlers/prompt.d.ts +0 -3
  206. package/dist/server/handlers/prompt.d.ts.map +0 -1
  207. package/dist/server/handlers/routes/agent-builder/handlers.d.ts +0 -22
  208. package/dist/server/handlers/routes/agent-builder/handlers.d.ts.map +0 -1
  209. package/dist/server/handlers/routes/agent-builder/router.d.ts +0 -4
  210. package/dist/server/handlers/routes/agent-builder/router.d.ts.map +0 -1
  211. package/dist/server/handlers/routes/agents/handlers.d.ts +0 -363
  212. package/dist/server/handlers/routes/agents/handlers.d.ts.map +0 -1
  213. package/dist/server/handlers/routes/agents/router.d.ts +0 -5
  214. package/dist/server/handlers/routes/agents/router.d.ts.map +0 -1
  215. package/dist/server/handlers/routes/agents/voice.d.ts +0 -18
  216. package/dist/server/handlers/routes/agents/voice.d.ts.map +0 -1
  217. package/dist/server/handlers/routes/logs/handlers.d.ts +0 -5
  218. package/dist/server/handlers/routes/logs/handlers.d.ts.map +0 -1
  219. package/dist/server/handlers/routes/logs/router.d.ts +0 -3
  220. package/dist/server/handlers/routes/logs/router.d.ts.map +0 -1
  221. package/dist/server/handlers/routes/mcp/handlers.d.ts +0 -139
  222. package/dist/server/handlers/routes/mcp/handlers.d.ts.map +0 -1
  223. package/dist/server/handlers/routes/mcp/router.d.ts +0 -4
  224. package/dist/server/handlers/routes/mcp/router.d.ts.map +0 -1
  225. package/dist/server/handlers/routes/memory/handlers.d.ts +0 -17
  226. package/dist/server/handlers/routes/memory/handlers.d.ts.map +0 -1
  227. package/dist/server/handlers/routes/memory/router.d.ts +0 -4
  228. package/dist/server/handlers/routes/memory/router.d.ts.map +0 -1
  229. package/dist/server/handlers/routes/observability/handlers.d.ts +0 -6
  230. package/dist/server/handlers/routes/observability/handlers.d.ts.map +0 -1
  231. package/dist/server/handlers/routes/observability/router.d.ts +0 -3
  232. package/dist/server/handlers/routes/observability/router.d.ts.map +0 -1
  233. package/dist/server/handlers/routes/scores/handlers.d.ts +0 -300
  234. package/dist/server/handlers/routes/scores/handlers.d.ts.map +0 -1
  235. package/dist/server/handlers/routes/scores/router.d.ts +0 -4
  236. package/dist/server/handlers/routes/scores/router.d.ts.map +0 -1
  237. package/dist/server/handlers/routes/tools/handlers.d.ts +0 -7
  238. package/dist/server/handlers/routes/tools/handlers.d.ts.map +0 -1
  239. package/dist/server/handlers/routes/tools/router.d.ts +0 -4
  240. package/dist/server/handlers/routes/tools/router.d.ts.map +0 -1
  241. package/dist/server/handlers/routes/vector/handlers.d.ts +0 -10
  242. package/dist/server/handlers/routes/vector/handlers.d.ts.map +0 -1
  243. package/dist/server/handlers/routes/vector/router.d.ts +0 -4
  244. package/dist/server/handlers/routes/vector/router.d.ts.map +0 -1
  245. package/dist/server/handlers/routes/workflows/handlers.d.ts +0 -22
  246. package/dist/server/handlers/routes/workflows/handlers.d.ts.map +0 -1
  247. package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts +0 -11
  248. package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts.map +0 -1
  249. package/dist/server/handlers/routes/workflows/router.d.ts +0 -4
  250. package/dist/server/handlers/routes/workflows/router.d.ts.map +0 -1
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
+ var chunk5TYVF4KJ_cjs = require('./chunk-5TYVF4KJ.cjs');
3
4
  var babel = require('@babel/core');
4
5
  var fs = require('fs');
5
6
  var promises = require('fs/promises');
6
7
  var path2 = require('path');
7
8
  var child_process = require('child_process');
8
- var localPkg = require('local-pkg');
9
9
  var url = require('url');
10
10
  var rollup = require('rollup');
11
11
  var originalEsbuild = require('rollup-plugin-esbuild');
12
12
  var commonjs = require('@rollup/plugin-commonjs');
13
13
  var resolveFrom2 = require('resolve-from');
14
+ var stripJsonComments = require('strip-json-comments');
14
15
  var typescriptPaths = require('typescript-paths');
15
16
  var rollupPlugin = require('@optimize-lodash/rollup-plugin');
16
17
  var json = require('@rollup/plugin-json');
@@ -18,9 +19,11 @@ var pkg = require('empathic/package');
18
19
  var findWorkspaces = require('find-workspaces');
19
20
  var logger = require('@mastra/core/logger');
20
21
  var virtual = require('@rollup/plugin-virtual');
22
+ var esm = require('fs-extra/esm');
21
23
  var module$1 = require('module');
24
+ var localPkg = require('local-pkg');
22
25
  var nodeResolve = require('@rollup/plugin-node-resolve');
23
- var esmShim = require('@rollup/plugin-esm-shim');
26
+ var originalEsmShim = require('@rollup/plugin-esm-shim');
24
27
  var posix = require('path/posix');
25
28
  var resolve = require('resolve.exports');
26
29
  var error = require('@mastra/core/error');
@@ -51,90 +54,26 @@ var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
51
54
  var originalEsbuild__default = /*#__PURE__*/_interopDefault(originalEsbuild);
52
55
  var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
53
56
  var resolveFrom2__default = /*#__PURE__*/_interopDefault(resolveFrom2);
57
+ var stripJsonComments__default = /*#__PURE__*/_interopDefault(stripJsonComments);
54
58
  var json__default = /*#__PURE__*/_interopDefault(json);
55
59
  var pkg__namespace = /*#__PURE__*/_interopNamespace(pkg);
56
60
  var virtual__default = /*#__PURE__*/_interopDefault(virtual);
57
61
  var nodeResolve__default = /*#__PURE__*/_interopDefault(nodeResolve);
58
- var esmShim__default = /*#__PURE__*/_interopDefault(esmShim);
62
+ var originalEsmShim__default = /*#__PURE__*/_interopDefault(originalEsmShim);
59
63
  var resolve__namespace = /*#__PURE__*/_interopNamespace(resolve);
60
64
 
61
- // src/build/analyze.ts
62
- function getPackageName(id) {
63
- const parts = id.split("/");
64
- if (id.startsWith("@")) {
65
- return parts.slice(0, 2).join("/");
66
- }
67
- return parts[0];
68
- }
69
- async function getPackageRootPath(packageName, parentPath) {
70
- let rootPath;
71
- try {
72
- let options = void 0;
73
- if (parentPath) {
74
- if (!parentPath.startsWith("file://")) {
75
- parentPath = url.pathToFileURL(parentPath).href;
76
- }
77
- options = {
78
- paths: [parentPath]
79
- };
80
- }
81
- const pkg2 = await localPkg.getPackageInfo(packageName, options);
82
- rootPath = pkg2?.rootPath ?? null;
83
- } catch (e) {
84
- rootPath = null;
85
- }
86
- return rootPath;
87
- }
88
- function getCompiledDepCachePath(rootPath, packageName) {
89
- return slash(path2.join(rootPath, "node_modules", ".cache", packageName));
90
- }
91
- function slash(path3) {
92
- const isExtendedLengthPath = path3.startsWith("\\\\?\\");
93
- if (isExtendedLengthPath) {
94
- return path3;
95
- }
96
- return path3.replaceAll("\\", "/");
97
- }
98
- function rollupSafeName(name, rootDir) {
99
- const rel = path2.relative(rootDir, name);
100
- let entry = slash(rel);
101
- entry = entry.replace(/^(\.\.\/)+/, "");
102
- entry = entry.replace(/^\/+/, "");
103
- entry = entry.replace(/^[A-Za-z]:\//, "");
104
- if (!entry) {
105
- entry = slash(path2.basename(name));
65
+ var ValidationError = class extends Error {
66
+ type;
67
+ stack;
68
+ constructor(args) {
69
+ super(args.message);
70
+ this.type = args.type;
71
+ this.stack = args.stack;
106
72
  }
107
- return entry;
108
- }
109
- var NATIVE_BINDING_LOADERS = [
110
- "node-gyp-build",
111
- "prebuild-install",
112
- "bindings",
113
- "node-addon-api",
114
- "node-pre-gyp",
115
- "nan"
116
- // Native Abstractions for Node.js
117
- ];
118
- function findNativePackageModule(moduleIds) {
119
- return moduleIds.find((id) => {
120
- if (id.startsWith("\0")) {
121
- return false;
122
- }
123
- if (!id.includes("/node_modules/")) {
124
- return false;
125
- }
126
- for (const loader of NATIVE_BINDING_LOADERS) {
127
- if (id.includes(`/${loader}/`) || id.includes(`/${loader}@`)) {
128
- return false;
129
- }
130
- }
131
- return true;
132
- });
133
- }
134
-
135
- // src/validator/validate.ts
73
+ };
136
74
  function spawn(command, args = [], options = {}) {
137
75
  return new Promise((resolve2, reject) => {
76
+ let validationError = null;
138
77
  const childProcess = child_process.spawn(command, args, {
139
78
  // stdio: 'inherit',
140
79
  ...options
@@ -144,113 +83,67 @@ function spawn(command, args = [], options = {}) {
144
83
  });
145
84
  let stderr = "";
146
85
  childProcess.stderr?.on("data", (message) => {
147
- stderr += message;
86
+ try {
87
+ validationError = JSON.parse(message.toString());
88
+ } catch {
89
+ stderr += message;
90
+ }
148
91
  });
149
92
  childProcess.on("close", (code) => {
150
93
  if (code === 0) {
151
94
  resolve2();
152
95
  } else {
153
- reject(new Error(stderr));
96
+ if (validationError) {
97
+ reject(new ValidationError(validationError));
98
+ } else {
99
+ reject(new Error(stderr));
100
+ }
154
101
  }
155
102
  });
156
103
  });
157
104
  }
158
- function validate(file) {
105
+ function validate(file, { injectESMShim = false, moduleResolveMapLocation }) {
106
+ let prefixCode = "";
107
+ if (injectESMShim) {
108
+ prefixCode = `import { fileURLToPath } from 'url';
109
+ import { dirname } from 'path';
110
+
111
+ globalThis.__filename = fileURLToPath(import.meta.url);
112
+ globalThis.__dirname = dirname(__filename);
113
+ `;
114
+ }
115
+ function errorHandler(err) {
116
+ console.error(
117
+ JSON.stringify({
118
+ type: err.name,
119
+ message: err.message,
120
+ stack: err.stack
121
+ })
122
+ );
123
+ process.exit(1);
124
+ }
159
125
  return spawn(
160
- "node",
126
+ process.execPath,
161
127
  [
162
128
  "--import",
163
129
  undefined("@mastra/deployer/loader"),
164
130
  "--input-type=module",
131
+ "--enable-source-maps",
165
132
  "-e",
166
- `import('file://${slash(file)}')`
133
+ `${prefixCode};import('${url.pathToFileURL(file).href}').catch(err => {
134
+ ${errorHandler.toString()}
135
+ errorHandler(err);
136
+ })`.replaceAll(/\n/g, "")
167
137
  ],
168
138
  {
139
+ env: {
140
+ ...process.env,
141
+ MODULE_MAP: `${moduleResolveMapLocation}`
142
+ },
169
143
  cwd: path2.dirname(file)
170
144
  }
171
145
  );
172
146
  }
173
- function removeAllOptionsFromMastraExcept(result, option, logger) {
174
- const t = babel__namespace.default.types;
175
- return {
176
- name: "remove-all-except-" + option + "-config",
177
- visitor: {
178
- ExportNamedDeclaration: {
179
- // remove all exports
180
- exit(path3) {
181
- path3.remove();
182
- }
183
- },
184
- NewExpression(path3, state) {
185
- const varDeclaratorPath = path3.findParent((path4) => t.isVariableDeclarator(path4.node));
186
- if (!varDeclaratorPath) {
187
- return;
188
- }
189
- const parentNode = path3.parentPath.node;
190
- if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
191
- return;
192
- }
193
- let mastraArgs = t.objectExpression([]);
194
- if (t.isObjectExpression(path3.node.arguments[0])) {
195
- mastraArgs = path3.node.arguments[0];
196
- }
197
- let configProperty = mastraArgs.properties.find(
198
- // @ts-ignore
199
- (prop) => prop.key.name === option
200
- );
201
- let configValue = t.objectExpression([]);
202
- const programPath = path3.scope.getProgramParent().path;
203
- if (!programPath) {
204
- return;
205
- }
206
- if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {
207
- result.hasCustomConfig = true;
208
- configValue = configProperty.value;
209
- if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {
210
- const configBinding = state.file.scope.getBinding(option);
211
- if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {
212
- const id = path3.scope.generateUidIdentifier(option);
213
- configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init));
214
- configValue = id;
215
- }
216
- }
217
- }
218
- const exportDeclaration = t.exportNamedDeclaration(
219
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]),
220
- []
221
- );
222
- programPath.node.body.push(exportDeclaration);
223
- },
224
- Program: {
225
- exit(path3) {
226
- const hasExport = path3.node.body.some(
227
- (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
228
- );
229
- if (!hasExport) {
230
- if (logger) {
231
- logger.warn(`Mastra ${option} config could not be extracted. Please make sure your entry file looks like this:
232
- export const mastra = new Mastra({
233
- ${option}: <value>
234
- })
235
-
236
- `);
237
- }
238
- const fallbackExportDeclaration = t.exportNamedDeclaration(
239
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
240
- []
241
- );
242
- path3.node.body.push(fallbackExportDeclaration);
243
- }
244
- }
245
- }
246
- }
247
- };
248
- }
249
-
250
- // src/build/babel/remove-all-options-bundler.ts
251
- function removeAllOptionsExceptBundler(result, logger) {
252
- return removeAllOptionsFromMastraExcept(result, "bundler", logger);
253
- }
254
147
  function esbuild(options = {}) {
255
148
  return originalEsbuild__default.default({
256
149
  target: "node20",
@@ -260,29 +153,90 @@ function esbuild(options = {}) {
260
153
  });
261
154
  }
262
155
  var PLUGIN_NAME = "tsconfig-paths";
156
+ function hasPaths(tsConfigPath) {
157
+ try {
158
+ const content = fs__default.default.readFileSync(tsConfigPath, "utf8");
159
+ const config = JSON.parse(stripJsonComments__default.default(content));
160
+ return !!(config.compilerOptions?.paths && Object.keys(config.compilerOptions.paths).length > 0 || typeof config.extends === "string" && config.extends.length > 0 || Array.isArray(config.extends) && config.extends.length > 0);
161
+ } catch {
162
+ return false;
163
+ }
164
+ }
263
165
  function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
264
- let handler;
166
+ const handlerCache = /* @__PURE__ */ new Map();
167
+ function findTsConfigForFile(filePath) {
168
+ let currentDir = path2__namespace.default.dirname(filePath);
169
+ const root = path2__namespace.default.parse(currentDir).root;
170
+ while (currentDir !== root) {
171
+ const tsConfigPath2 = path2__namespace.default.join(currentDir, "tsconfig.json");
172
+ if (fs__default.default.existsSync(tsConfigPath2)) {
173
+ if (hasPaths(tsConfigPath2)) {
174
+ return tsConfigPath2;
175
+ }
176
+ }
177
+ const tsConfigBasePath = path2__namespace.default.join(currentDir, "tsconfig.base.json");
178
+ if (fs__default.default.existsSync(tsConfigBasePath)) {
179
+ if (hasPaths(tsConfigBasePath)) {
180
+ return tsConfigBasePath;
181
+ }
182
+ }
183
+ currentDir = path2__namespace.default.dirname(currentDir);
184
+ }
185
+ return null;
186
+ }
187
+ function getHandlerForFile(filePath) {
188
+ if (tsConfigPath && typeof tsConfigPath === "string") {
189
+ if (!handlerCache.has(tsConfigPath)) {
190
+ handlerCache.set(
191
+ tsConfigPath,
192
+ typescriptPaths.createHandler({
193
+ log: () => {
194
+ },
195
+ tsConfigPath,
196
+ respectCoreModule,
197
+ falllback: (moduleName) => fs__default.default.existsSync(moduleName)
198
+ })
199
+ );
200
+ }
201
+ return handlerCache.get(tsConfigPath);
202
+ }
203
+ const configPath = findTsConfigForFile(filePath);
204
+ if (!configPath) {
205
+ return null;
206
+ }
207
+ if (!handlerCache.has(configPath)) {
208
+ handlerCache.set(
209
+ configPath,
210
+ typescriptPaths.createHandler({
211
+ log: () => {
212
+ },
213
+ tsConfigPath: configPath,
214
+ respectCoreModule,
215
+ falllback: (moduleName) => fs__default.default.existsSync(moduleName)
216
+ })
217
+ );
218
+ }
219
+ return handlerCache.get(configPath);
220
+ }
221
+ function resolveAlias(request, importer) {
222
+ const dynamicHandler = getHandlerForFile(importer);
223
+ if (!dynamicHandler) {
224
+ return null;
225
+ }
226
+ const resolved = dynamicHandler(request, path2.normalize(importer));
227
+ return resolved;
228
+ }
265
229
  return {
266
230
  name: PLUGIN_NAME,
267
- buildStart() {
268
- handler = typescriptPaths.createHandler({
269
- log: () => {
270
- },
271
- tsConfigPath,
272
- respectCoreModule,
273
- falllback: (moduleName) => fs__default.default.existsSync(moduleName)
274
- });
275
- return;
276
- },
277
231
  async resolveId(request, importer, options) {
278
- if (!importer || request.startsWith("\0")) {
232
+ if (!importer || request.startsWith("\0") || importer.charCodeAt(0) === 0) {
279
233
  return null;
280
234
  }
281
- const moduleName = handler?.(request, path2.normalize(importer));
235
+ const moduleName = resolveAlias(request, importer);
282
236
  if (!moduleName) {
283
237
  let importerMeta = {};
284
- const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });
285
- if (!resolved) {
238
+ const resolved2 = await this.resolve(request, importer, { skipSelf: true, ...options });
239
+ if (!resolved2) {
286
240
  return null;
287
241
  }
288
242
  if (localResolve) {
@@ -290,37 +244,42 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
290
244
  importerMeta = importerInfo?.meta || {};
291
245
  if (!request.startsWith("./") && !request.startsWith("../") && importerMeta?.[PLUGIN_NAME]?.resolved) {
292
246
  return {
293
- ...resolved,
247
+ ...resolved2,
294
248
  external: !request.startsWith("hono/") && request !== "hono"
295
249
  };
296
250
  }
297
251
  }
298
252
  return {
299
- ...resolved,
253
+ ...resolved2,
300
254
  meta: {
301
- ...resolved.meta || {},
255
+ ...resolved2.meta || {},
302
256
  ...importerMeta
303
257
  }
304
258
  };
305
259
  }
306
260
  if (!path2__namespace.default.extname(moduleName)) {
307
- const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
308
- if (!resolved) {
261
+ const resolved2 = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
262
+ if (!resolved2) {
309
263
  return null;
310
264
  }
311
265
  return {
312
- ...resolved,
266
+ ...resolved2,
313
267
  meta: {
314
- ...resolved.meta,
268
+ ...resolved2.meta,
315
269
  [PLUGIN_NAME]: {
316
270
  resolved: true
317
271
  }
318
272
  }
319
273
  };
320
274
  }
275
+ const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
276
+ if (!resolved) {
277
+ return null;
278
+ }
321
279
  return {
322
- id: moduleName,
280
+ ...resolved,
323
281
  meta: {
282
+ ...resolved.meta,
324
283
  [PLUGIN_NAME]: {
325
284
  resolved: true
326
285
  }
@@ -402,7 +361,117 @@ function recursiveRemoveNonReferencedNodes(code) {
402
361
  );
403
362
  });
404
363
  }
405
- function extractMastraOptionBundler(name, entryFile, transformer, result, logger) {
364
+ function removeAllOptionsFromMastraExcept(result, option, logger) {
365
+ const t = babel__namespace.default.types;
366
+ return {
367
+ name: "remove-all-except-" + option + "-config",
368
+ visitor: {
369
+ ExportNamedDeclaration: {
370
+ // remove all exports
371
+ exit(path3) {
372
+ path3.remove();
373
+ }
374
+ },
375
+ NewExpression(path3, state) {
376
+ const varDeclaratorPath = path3.findParent((path4) => t.isVariableDeclarator(path4.node));
377
+ if (!varDeclaratorPath) {
378
+ return;
379
+ }
380
+ const parentNode = path3.parentPath.node;
381
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
382
+ return;
383
+ }
384
+ let mastraArgs = t.objectExpression([]);
385
+ if (t.isObjectExpression(path3.node.arguments[0])) {
386
+ mastraArgs = path3.node.arguments[0];
387
+ }
388
+ let configProperty = mastraArgs.properties.find(
389
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option
390
+ );
391
+ let configValue = t.objectExpression([]);
392
+ const programPath = path3.scope.getProgramParent().path;
393
+ if (!programPath) {
394
+ return;
395
+ }
396
+ if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {
397
+ result.hasCustomConfig = true;
398
+ configValue = configProperty.value;
399
+ if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {
400
+ const configBinding = state.file.scope.getBinding(option);
401
+ if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {
402
+ const id = path3.scope.generateUidIdentifier(option);
403
+ configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init));
404
+ configValue = id;
405
+ }
406
+ }
407
+ }
408
+ const exportDeclaration = t.exportNamedDeclaration(
409
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]),
410
+ []
411
+ );
412
+ programPath.node.body.push(exportDeclaration);
413
+ },
414
+ Program: {
415
+ exit(path3) {
416
+ const hasExport = path3.node.body.some(
417
+ (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
418
+ );
419
+ if (!hasExport) {
420
+ if (logger) {
421
+ logger.warn(`Mastra ${option} config could not be extracted. Please make sure your entry file looks like this:
422
+ export const mastra = new Mastra({
423
+ ${option}: <value>
424
+ })
425
+
426
+ `);
427
+ }
428
+ const fallbackExportDeclaration = t.exportNamedDeclaration(
429
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
430
+ []
431
+ );
432
+ path3.node.body.push(fallbackExportDeclaration);
433
+ }
434
+ }
435
+ }
436
+ }
437
+ };
438
+ }
439
+
440
+ // src/build/plugins/remove-all-except.ts
441
+ function removeAllOptionsFromMastraExceptPlugin(mastraEntry, name, result, options) {
442
+ return {
443
+ name: `remove-${name}`,
444
+ transform(code, id) {
445
+ if (id !== mastraEntry) {
446
+ return;
447
+ }
448
+ return new Promise((resolve2, reject) => {
449
+ babel__namespace.transform(
450
+ code,
451
+ {
452
+ babelrc: false,
453
+ configFile: false,
454
+ filename: id,
455
+ plugins: [removeAllOptionsFromMastraExcept(result, name, options?.logger)],
456
+ sourceMaps: options?.sourcemap
457
+ },
458
+ (err, result2) => {
459
+ if (err) {
460
+ return reject(err);
461
+ }
462
+ resolve2({
463
+ code: result2.code,
464
+ map: result2.map
465
+ });
466
+ }
467
+ );
468
+ });
469
+ }
470
+ };
471
+ }
472
+
473
+ // src/build/shared/extract-mastra-option.ts
474
+ function extractMastraOptionBundler(name, entryFile, result, logger) {
406
475
  return rollup.rollup({
407
476
  logLevel: "silent",
408
477
  input: {
@@ -423,34 +492,7 @@ function extractMastraOptionBundler(name, entryFile, transformer, result, logger
423
492
  ignoreTryCatch: false
424
493
  }),
425
494
  json__default.default(),
426
- {
427
- name: `extract-${name}-config`,
428
- transform(code, id) {
429
- if (id !== entryFile) {
430
- return;
431
- }
432
- return new Promise((resolve2, reject) => {
433
- babel__namespace.transform(
434
- code,
435
- {
436
- babelrc: false,
437
- configFile: false,
438
- filename: id,
439
- plugins: [transformer(result, logger)]
440
- },
441
- (err, result2) => {
442
- if (err) {
443
- return reject(err);
444
- }
445
- resolve2({
446
- code: result2.code,
447
- map: result2.map
448
- });
449
- }
450
- );
451
- });
452
- }
453
- },
495
+ removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),
454
496
  // let esbuild remove all unused imports
455
497
  esbuild(),
456
498
  {
@@ -467,11 +509,11 @@ function extractMastraOptionBundler(name, entryFile, transformer, result, logger
467
509
  ]
468
510
  });
469
511
  }
470
- async function extractMastraOption(name, entryFile, transformer, outputDir, logger) {
512
+ async function extractMastraOption(name, entryFile, outputDir, logger) {
471
513
  const result = {
472
514
  hasCustomConfig: false
473
515
  };
474
- const bundler = await extractMastraOptionBundler(name, entryFile, transformer, result, logger);
516
+ const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);
475
517
  const output = await bundler.write({
476
518
  dir: outputDir,
477
519
  format: "es",
@@ -481,7 +523,7 @@ async function extractMastraOption(name, entryFile, transformer, outputDir, logg
481
523
  const configPath = `${outputDir}/${name}-config.mjs`;
482
524
  return {
483
525
  bundleOutput: output,
484
- getConfig: () => import(`file:${configPath}`).then((m) => m[name])
526
+ getConfig: () => import(url.pathToFileURL(configPath).href).then((m) => m[name])
485
527
  };
486
528
  }
487
529
  return null;
@@ -489,13 +531,7 @@ async function extractMastraOption(name, entryFile, transformer, outputDir, logg
489
531
 
490
532
  // src/build/bundlerOptions.ts
491
533
  async function getBundlerOptions(entryFile, outputDir, logger) {
492
- const result = await extractMastraOption(
493
- "bundler",
494
- entryFile,
495
- removeAllOptionsExceptBundler,
496
- outputDir,
497
- logger
498
- );
534
+ const result = await extractMastraOption("bundler", entryFile, outputDir, logger);
499
535
  if (!result) {
500
536
  return null;
501
537
  }
@@ -539,7 +575,7 @@ async function getWorkspaceInformation({
539
575
  mastraEntryFile
540
576
  }) {
541
577
  const closestPkgJson = pkg__namespace.up({ cwd: path2.dirname(mastraEntryFile) });
542
- const location = closestPkgJson ? path2.dirname(slash(closestPkgJson)) : slash(process.cwd());
578
+ const location = closestPkgJson ? path2.dirname(chunk5TYVF4KJ_cjs.slash(closestPkgJson)) : chunk5TYVF4KJ_cjs.slash(process.cwd());
543
579
  const workspaces = await findWorkspaces.findWorkspaces(dir, { cache: workspacesCache });
544
580
  const _workspaceMap = new Map(
545
581
  workspaces?.map((workspace) => [
@@ -564,8 +600,57 @@ function isNodeBuiltin(dep) {
564
600
  const [pkg2] = dep.split("/");
565
601
  return dep.startsWith("node:") || module$1.builtinModules.includes(dep) || module$1.builtinModules.includes(pkg2);
566
602
  }
603
+ async function getPackageRootPath(packageName, parentPath) {
604
+ let rootPath;
605
+ try {
606
+ let options = void 0;
607
+ if (parentPath) {
608
+ if (!parentPath.startsWith("file://")) {
609
+ parentPath = url.pathToFileURL(parentPath).href;
610
+ }
611
+ options = {
612
+ paths: [parentPath]
613
+ };
614
+ }
615
+ const pkg2 = await localPkg.getPackageInfo(packageName, options);
616
+ rootPath = pkg2?.rootPath ?? null;
617
+ } catch (e) {
618
+ rootPath = null;
619
+ }
620
+ return rootPath;
621
+ }
622
+
623
+ // src/build/analyze/constants.ts
624
+ var DEPS_TO_IGNORE = ["#tools"];
625
+ var GLOBAL_EXTERNALS = [
626
+ "pino",
627
+ "pino-pretty",
628
+ "@libsql/client",
629
+ "pg",
630
+ "libsql",
631
+ "#tools",
632
+ "typescript",
633
+ "undici",
634
+ "readable-stream"
635
+ ];
636
+ var DEPRECATED_EXTERNALS = ["fastembed", "nodemailer", "jsdom", "sqlite3"];
567
637
  function removeDeployer() {
568
638
  const t = babel__namespace.default.types;
639
+ function removeDeployerFromObject(objectExpr, scope) {
640
+ const deployerProp = objectExpr.properties.find(
641
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
642
+ );
643
+ if (deployerProp) {
644
+ objectExpr.properties = objectExpr.properties.filter((prop) => prop !== deployerProp);
645
+ if (t.isIdentifier(deployerProp.value)) {
646
+ const deployerBinding = scope.getBinding(deployerProp.value.name);
647
+ if (deployerBinding) {
648
+ deployerBinding.path?.parentPath?.remove();
649
+ }
650
+ }
651
+ }
652
+ return deployerProp;
653
+ }
569
654
  return {
570
655
  name: "remove-deployer",
571
656
  visitor: {
@@ -581,23 +666,30 @@ function removeDeployer() {
581
666
  if (!state.hasReplaced) {
582
667
  state.hasReplaced = true;
583
668
  const newMastraObj = t.cloneNode(path3.node);
584
- if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {
585
- const deployer = newMastraObj.arguments[0].properties.find(
586
- (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
587
- );
588
- if (!deployer) {
589
- return;
669
+ if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.length) {
670
+ const objectArg = newMastraObj.arguments[0];
671
+ let foundDeployer = false;
672
+ const directDeployer = removeDeployerFromObject(objectArg, state.file.scope);
673
+ if (directDeployer) {
674
+ foundDeployer = true;
590
675
  }
591
- newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(
592
- (prop) => prop !== deployer
593
- );
594
- if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {
595
- const deployerBinding = state.file.scope.getBinding(deployer.value.name);
596
- if (deployerBinding) {
597
- deployerBinding?.path?.parentPath?.remove();
676
+ for (const prop of objectArg.properties) {
677
+ if (t.isSpreadElement(prop) && t.isIdentifier(prop.argument)) {
678
+ const spreadBinding = state.file.scope.getBinding(prop.argument.name);
679
+ if (spreadBinding?.path && t.isVariableDeclarator(spreadBinding.path.node)) {
680
+ const init = spreadBinding.path.node.init;
681
+ if (t.isObjectExpression(init)) {
682
+ const spreadDeployer = removeDeployerFromObject(init, state.file.scope);
683
+ if (spreadDeployer) {
684
+ foundDeployer = true;
685
+ }
686
+ }
687
+ }
598
688
  }
599
689
  }
600
- path3.replaceWith(newMastraObj);
690
+ if (foundDeployer) {
691
+ path3.replaceWith(newMastraObj);
692
+ }
601
693
  }
602
694
  }
603
695
  }
@@ -638,23 +730,9 @@ function removeDeployer2(mastraEntry, options) {
638
730
  };
639
731
  }
640
732
 
641
- // src/build/analyze/constants.ts
642
- var DEPS_TO_IGNORE = ["#tools"];
643
- var GLOBAL_EXTERNALS = [
644
- "pino",
645
- "pino-pretty",
646
- "@libsql/client",
647
- "pg",
648
- "libsql",
649
- "#tools",
650
- "typescript",
651
- "undici"
652
- ];
653
- var DEPRECATED_EXTERNALS = ["fastembed", "nodemailer", "jsdom", "sqlite3"];
654
-
655
733
  // src/build/analyze/analyzeEntry.ts
656
734
  function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }) {
657
- const normalizedMastraEntry = slash(mastraEntry);
735
+ const normalizedMastraEntry = chunk5TYVF4KJ_cjs.slash(mastraEntry);
658
736
  let virtualPlugin = null;
659
737
  if (isVirtualFile) {
660
738
  virtualPlugin = virtual__default.default({
@@ -673,7 +751,7 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
673
751
  name: "custom-alias-resolver",
674
752
  resolveId(id) {
675
753
  if (id === "#server") {
676
- return slash(url.fileURLToPath(undefined("@mastra/deployer/server")));
754
+ return chunk5TYVF4KJ_cjs.slash(url.fileURLToPath(undefined("@mastra/deployer/server")));
677
755
  }
678
756
  if (id === "#mastra") {
679
757
  return normalizedMastraEntry;
@@ -691,14 +769,17 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
691
769
  transformMixedEsModules: true,
692
770
  extensions: [".js", ".ts"]
693
771
  }),
694
- removeDeployer2(mastraEntry, { sourcemap: sourcemapEnabled }),
772
+ removeDeployer2(mastraEntry, {
773
+ sourcemap: sourcemapEnabled
774
+ }),
695
775
  esbuild()
696
776
  ]
697
777
  );
698
778
  return plugins;
699
779
  }
700
780
  async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, initialDepsToOptimize, {
701
- logger: logger$1
781
+ logger: logger$1,
782
+ shouldCheckTransitiveDependencies
702
783
  }) {
703
784
  const depsToOptimize = /* @__PURE__ */ new Map();
704
785
  if (!output.facadeModuleId) {
@@ -711,18 +792,31 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
711
792
  entryRootPath = await getPackageRootPath(output.facadeModuleId) || projectRoot;
712
793
  }
713
794
  for (const [dependency, bindings] of Object.entries(output.importedBindings)) {
714
- if (isNodeBuiltin(dependency) || DEPS_TO_IGNORE.includes(dependency)) {
795
+ if (isNodeBuiltin(dependency) || dependency.startsWith("#")) {
715
796
  continue;
716
797
  }
717
- const pkgName = getPackageName(dependency);
798
+ const pkgName = chunk5TYVF4KJ_cjs.getPackageName(dependency);
718
799
  let rootPath = null;
719
800
  let isWorkspace = false;
801
+ let version;
720
802
  if (pkgName) {
721
803
  rootPath = await getPackageRootPath(dependency, entryRootPath);
722
804
  isWorkspace = workspaceMap.has(pkgName);
805
+ if (rootPath) {
806
+ try {
807
+ const pkgJson = await esm.readJSON(`${rootPath}/package.json`);
808
+ version = pkgJson.version;
809
+ } catch {
810
+ }
811
+ }
723
812
  }
724
- const normalizedRootPath = rootPath ? slash(rootPath) : null;
725
- depsToOptimize.set(dependency, { exports: bindings, rootPath: normalizedRootPath, isWorkspace });
813
+ const normalizedRootPath = rootPath ? chunk5TYVF4KJ_cjs.slash(rootPath) : null;
814
+ depsToOptimize.set(dependency, {
815
+ exports: bindings,
816
+ rootPath: normalizedRootPath,
817
+ isWorkspace,
818
+ version
819
+ });
726
820
  }
727
821
  async function checkTransitiveDependencies(internalMap, maxDepth = 10, currentDepth = 0) {
728
822
  if (currentDepth >= maxDepth) {
@@ -766,12 +860,32 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
766
860
  await checkTransitiveDependencies(internalMap, maxDepth, currentDepth + 1);
767
861
  }
768
862
  }
769
- await checkTransitiveDependencies(initialDepsToOptimize);
863
+ if (shouldCheckTransitiveDependencies) {
864
+ await checkTransitiveDependencies(initialDepsToOptimize);
865
+ }
770
866
  const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
771
867
  if (dynamicImports.length) {
772
868
  for (const dynamicImport of dynamicImports) {
773
869
  if (!depsToOptimize.has(dynamicImport) && !isNodeBuiltin(dynamicImport)) {
774
- depsToOptimize.set(dynamicImport, { exports: ["*"], rootPath: null, isWorkspace: false });
870
+ const pkgName = chunk5TYVF4KJ_cjs.getPackageName(dynamicImport);
871
+ let version;
872
+ let rootPath = null;
873
+ if (pkgName) {
874
+ rootPath = await getPackageRootPath(dynamicImport, entryRootPath);
875
+ if (rootPath) {
876
+ try {
877
+ const pkgJson = await esm.readJSON(`${rootPath}/package.json`);
878
+ version = pkgJson.version;
879
+ } catch {
880
+ }
881
+ }
882
+ }
883
+ depsToOptimize.set(dynamicImport, {
884
+ exports: ["*"],
885
+ rootPath: rootPath ? chunk5TYVF4KJ_cjs.slash(rootPath) : null,
886
+ isWorkspace: false,
887
+ version
888
+ });
775
889
  }
776
890
  }
777
891
  }
@@ -785,13 +899,14 @@ async function analyzeEntry({
785
899
  sourcemapEnabled,
786
900
  workspaceMap,
787
901
  projectRoot,
788
- initialDepsToOptimize = /* @__PURE__ */ new Map()
902
+ initialDepsToOptimize = /* @__PURE__ */ new Map(),
789
903
  // used to avoid infinite recursion
904
+ shouldCheckTransitiveDependencies = false
790
905
  }) {
791
906
  const optimizerBundler = await rollup.rollup({
792
907
  logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
793
908
  input: isVirtualFile ? "#entry" : entry,
794
- treeshake: "smallest",
909
+ treeshake: false,
795
910
  preserveSymlinks: true,
796
911
  plugins: getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }),
797
912
  external: DEPS_TO_IGNORE
@@ -807,7 +922,8 @@ async function analyzeEntry({
807
922
  projectRoot,
808
923
  initialDepsToOptimize,
809
924
  {
810
- logger
925
+ logger,
926
+ shouldCheckTransitiveDependencies
811
927
  }
812
928
  );
813
929
  return {
@@ -818,6 +934,27 @@ async function analyzeEntry({
818
934
  }
819
935
  };
820
936
  }
937
+ var FilenameDeclarationRegex = /(?:const|let|var)\s+__filename/;
938
+ var DirnameDeclarationRegex = /(?:const|let|var)\s+__dirname/;
939
+ function esmShim() {
940
+ const original = originalEsmShim__default.default();
941
+ return {
942
+ name: "esm-shim",
943
+ renderChunk(code, chunk, opts, meta) {
944
+ const hasFilename = code.includes("__filename");
945
+ const hasDirname = code.includes("__dirname");
946
+ const userDeclaredFilename = hasFilename && FilenameDeclarationRegex.test(code);
947
+ const userDeclaredDirname = hasDirname && DirnameDeclarationRegex.test(code);
948
+ if (userDeclaredFilename || userDeclaredDirname) {
949
+ return null;
950
+ }
951
+ if (typeof original.renderChunk === "function") {
952
+ return original.renderChunk.call(this, code, chunk, opts, meta);
953
+ }
954
+ return null;
955
+ }
956
+ };
957
+ }
821
958
  function aliasHono() {
822
959
  return {
823
960
  name: "hono-alias",
@@ -830,8 +967,116 @@ function aliasHono() {
830
967
  }
831
968
  };
832
969
  }
970
+ function nodeGypDetector() {
971
+ const modulesToTrack = /* @__PURE__ */ new Set();
972
+ const modulesToTrackPackageInfo = /* @__PURE__ */ new Map();
973
+ return {
974
+ name: "node-gyp-build-detector",
975
+ moduleParsed(info) {
976
+ if (!info.meta?.commonjs?.requires?.length) {
977
+ return;
978
+ }
979
+ const hasNodeGypBuild = info.meta.commonjs.requires.some(
980
+ (m) => m?.resolved?.id.endsWith("node-gyp-build/index.js")
981
+ );
982
+ if (!hasNodeGypBuild) {
983
+ return;
984
+ }
985
+ modulesToTrack.add(info.id);
986
+ modulesToTrackPackageInfo.set(info.id, localPkg.getPackageInfo(info.id));
987
+ },
988
+ async generateBundle(options, bundle) {
989
+ const binaryMapByChunk = /* @__PURE__ */ new Map();
990
+ for (const [fileName, chunk] of Object.entries(bundle)) {
991
+ if (chunk.type === "chunk") {
992
+ for (const moduleId of chunk.moduleIds) {
993
+ if (modulesToTrackPackageInfo.has(moduleId)) {
994
+ const pkgInfo = await modulesToTrackPackageInfo.get(moduleId);
995
+ if (!binaryMapByChunk.has(fileName)) {
996
+ binaryMapByChunk.set(fileName, /* @__PURE__ */ new Set());
997
+ }
998
+ if (pkgInfo?.packageJson?.name) {
999
+ binaryMapByChunk.get(fileName).add(pkgInfo.packageJson.name);
1000
+ }
1001
+ }
1002
+ }
1003
+ }
1004
+ }
1005
+ const binaryMapJson = Object.fromEntries(
1006
+ Array.from(binaryMapByChunk.entries()).map(([key, value]) => [key, Array.from(value)])
1007
+ );
1008
+ this.emitFile({
1009
+ type: "asset",
1010
+ name: "binary-map.json",
1011
+ source: `${JSON.stringify(binaryMapJson, null, 2)}`
1012
+ });
1013
+ }
1014
+ };
1015
+ }
1016
+
1017
+ // src/build/plugins/subpath-externals-resolver.ts
1018
+ function subpathExternalsResolver(externals) {
1019
+ return {
1020
+ name: "subpath-externals-resolver",
1021
+ resolveId(id) {
1022
+ if (id.startsWith(".") || id.startsWith("/")) {
1023
+ return null;
1024
+ }
1025
+ const isPartOfExternals = externals.some((external) => chunk5TYVF4KJ_cjs.isDependencyPartOfPackage(id, external));
1026
+ if (isPartOfExternals) {
1027
+ return {
1028
+ id,
1029
+ external: true
1030
+ };
1031
+ }
1032
+ }
1033
+ };
1034
+ }
1035
+ function moduleResolveMap(externals, projectRoot) {
1036
+ const importMap = /* @__PURE__ */ new Map();
1037
+ return {
1038
+ name: "module-resolve-map",
1039
+ moduleParsed(info) {
1040
+ if (info.importedIds.length === 0 || !info.id) {
1041
+ return;
1042
+ }
1043
+ for (const importedId of info.importedIds) {
1044
+ for (const external of externals) {
1045
+ if (chunk5TYVF4KJ_cjs.isDependencyPartOfPackage(importedId, external)) {
1046
+ importMap.set(external, info.id);
1047
+ }
1048
+ }
1049
+ }
1050
+ },
1051
+ async generateBundle(options, bundle) {
1052
+ const resolveMap = /* @__PURE__ */ new Map();
1053
+ for (const [fileName, chunk] of Object.entries(bundle)) {
1054
+ if (chunk.type === "chunk") {
1055
+ for (const [external, resolvedFrom] of importMap) {
1056
+ if (chunk.moduleIds.includes(resolvedFrom)) {
1057
+ const fullPath = url.pathToFileURL(chunk5TYVF4KJ_cjs.slash(path2.join(projectRoot, fileName))).toString();
1058
+ const innerMap = resolveMap.get(fullPath) || /* @__PURE__ */ new Map();
1059
+ innerMap.set(external, url.pathToFileURL(chunk5TYVF4KJ_cjs.slash(resolvedFrom)).toString());
1060
+ resolveMap.set(fullPath, innerMap);
1061
+ }
1062
+ }
1063
+ }
1064
+ }
1065
+ const resolveMapJson = Object.fromEntries(
1066
+ Array.from(resolveMap.entries()).map(([key, value]) => [key, Object.fromEntries(value.entries())])
1067
+ );
1068
+ this.emitFile({
1069
+ type: "asset",
1070
+ name: "module-resolve-map.json",
1071
+ source: `${JSON.stringify(resolveMapJson, null, 2)}`
1072
+ });
1073
+ }
1074
+ };
1075
+ }
1076
+
1077
+ // src/build/analyze/bundleExternals.ts
833
1078
  function prepareEntryFileName(name, rootDir) {
834
- return rollupSafeName(name, rootDir);
1079
+ return chunk5TYVF4KJ_cjs.rollupSafeName(name, rootDir);
835
1080
  }
836
1081
  function createVirtualDependencies(depsToOptimize, {
837
1082
  projectRoot,
@@ -839,7 +1084,7 @@ function createVirtualDependencies(depsToOptimize, {
839
1084
  outputDir,
840
1085
  bundlerOptions
841
1086
  }) {
842
- const { isDev = false } = bundlerOptions || {};
1087
+ const { isDev = false, externalsPreset = false } = bundlerOptions || {};
843
1088
  const fileNameToDependencyMap = /* @__PURE__ */ new Map();
844
1089
  const optimizedDependencyEntries = /* @__PURE__ */ new Map();
845
1090
  const rootDir = workspaceRoot || projectRoot;
@@ -871,7 +1116,7 @@ function createVirtualDependencies(depsToOptimize, {
871
1116
  virtual: virtualFile.join("\n")
872
1117
  });
873
1118
  }
874
- if (isDev) {
1119
+ if (isDev || externalsPreset) {
875
1120
  for (const [dep, { isWorkspace, rootPath }] of depsToOptimize.entries()) {
876
1121
  if (!isWorkspace || !rootPath || !workspaceRoot) {
877
1122
  continue;
@@ -881,7 +1126,7 @@ function createVirtualDependencies(depsToOptimize, {
881
1126
  continue;
882
1127
  }
883
1128
  const fileName = posix.basename(currentDepPath.name);
884
- const entryName = prepareEntryFileName(getCompiledDepCachePath(rootPath, fileName), rootDir);
1129
+ const entryName = prepareEntryFileName(chunk5TYVF4KJ_cjs.getCompiledDepCachePath(rootPath, fileName), rootDir);
885
1130
  fileNameToDependencyMap.set(entryName, dep);
886
1131
  optimizedDependencyEntries.set(dep, {
887
1132
  ...currentDepPath,
@@ -895,13 +1140,14 @@ async function getInputPlugins2(virtualDependencies, {
895
1140
  transpilePackages,
896
1141
  workspaceMap,
897
1142
  bundlerOptions,
898
- rootDir
1143
+ rootDir,
1144
+ externals
899
1145
  }) {
900
1146
  const transpilePackagesMap = /* @__PURE__ */ new Map();
901
1147
  for (const pkg2 of transpilePackages) {
902
1148
  const dir = await getPackageRootPath(pkg2);
903
1149
  if (dir) {
904
- transpilePackagesMap.set(pkg2, slash(dir));
1150
+ transpilePackagesMap.set(pkg2, chunk5TYVF4KJ_cjs.slash(dir));
905
1151
  } else {
906
1152
  transpilePackagesMap.set(pkg2, workspaceMap.get(pkg2)?.location ?? pkg2);
907
1153
  }
@@ -916,6 +1162,7 @@ async function getInputPlugins2(virtualDependencies, {
916
1162
  {}
917
1163
  )
918
1164
  ),
1165
+ subpathExternalsResolver(externals),
919
1166
  transpilePackagesMap.size ? esbuild({
920
1167
  format: "esm",
921
1168
  include: [...transpilePackagesMap.values()].map((p) => {
@@ -926,7 +1173,7 @@ async function getInputPlugins2(virtualDependencies, {
926
1173
  }
927
1174
  })
928
1175
  }) : null,
929
- bundlerOptions.isDev ? {
1176
+ bundlerOptions.noBundling ? {
930
1177
  name: "alias-optimized-deps",
931
1178
  async resolveId(id, importer, options) {
932
1179
  if (!virtualDependencies.has(id)) {
@@ -944,7 +1191,8 @@ async function getInputPlugins2(virtualDependencies, {
944
1191
  if (!resolvedPath) {
945
1192
  resolvedPath = pkgJson.main ?? "index.js";
946
1193
  }
947
- return await this.resolve(path2__namespace.posix.join(packageRootPath, resolvedPath), importer, options);
1194
+ const resolved = await this.resolve(path2__namespace.posix.join(packageRootPath, resolvedPath), importer, options);
1195
+ return resolved;
948
1196
  }
949
1197
  } : null,
950
1198
  rollupPlugin.optimizeLodashImports({
@@ -955,14 +1203,16 @@ async function getInputPlugins2(virtualDependencies, {
955
1203
  transformMixedEsModules: true,
956
1204
  ignoreTryCatch: false
957
1205
  }),
958
- bundlerOptions.isDev ? null : nodeResolve__default.default({
1206
+ bundlerOptions.noBundling ? null : nodeResolve__default.default({
959
1207
  preferBuiltins: true,
960
1208
  exportConditions: ["node"]
961
1209
  }),
962
- bundlerOptions.isDev ? esmShim__default.default() : null,
1210
+ bundlerOptions.noBundling ? esmShim() : null,
963
1211
  // hono is imported from deployer, so we need to resolve from here instead of the project root
964
1212
  aliasHono(),
965
1213
  json__default.default(),
1214
+ nodeGypDetector(),
1215
+ moduleResolveMap(externals, rootDir),
966
1216
  {
967
1217
  name: "not-found-resolver",
968
1218
  resolveId: {
@@ -1010,6 +1260,16 @@ async function buildExternalDependencies(virtualDependencies, {
1010
1260
  if (virtualDependencies.size === 0) {
1011
1261
  return [];
1012
1262
  }
1263
+ const noBundling = bundlerOptions.isDev || bundlerOptions.externalsPreset;
1264
+ const plugins = await getInputPlugins2(virtualDependencies, {
1265
+ transpilePackages: packagesToTranspile,
1266
+ workspaceMap,
1267
+ bundlerOptions: {
1268
+ noBundling
1269
+ },
1270
+ rootDir,
1271
+ externals
1272
+ });
1013
1273
  const bundler = await rollup.rollup({
1014
1274
  logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
1015
1275
  input: Array.from(virtualDependencies.entries()).reduce(
@@ -1020,30 +1280,27 @@ async function buildExternalDependencies(virtualDependencies, {
1020
1280
  {}
1021
1281
  ),
1022
1282
  external: externals,
1023
- treeshake: "smallest",
1024
- plugins: getInputPlugins2(virtualDependencies, {
1025
- transpilePackages: packagesToTranspile,
1026
- workspaceMap,
1027
- bundlerOptions,
1028
- rootDir
1029
- })
1283
+ treeshake: noBundling ? false : "safest",
1284
+ plugins
1030
1285
  });
1031
1286
  const outputDirRelative = prepareEntryFileName(outputDir, rootDir);
1032
1287
  const { output } = await bundler.write({
1033
1288
  format: "esm",
1034
1289
  dir: rootDir,
1035
1290
  entryFileNames: "[name].mjs",
1291
+ // used to get the filename of the actual error
1292
+ sourcemap: true,
1036
1293
  /**
1037
1294
  * Rollup creates chunks for common dependencies, but these chunks are by default written to the root directory instead of respecting the entryFileNames structure.
1038
1295
  * So we want to write them to the `.mastra/output` folder as well.
1039
1296
  */
1040
1297
  chunkFileNames: (chunkInfo) => {
1041
- if (bundlerOptions.isDev) {
1298
+ if (noBundling) {
1042
1299
  const importedFromPackages = /* @__PURE__ */ new Set();
1043
1300
  for (const moduleId of chunkInfo.moduleIds) {
1044
- const normalized = slash(moduleId);
1301
+ const normalized = chunk5TYVF4KJ_cjs.slash(moduleId);
1045
1302
  for (const [pkgName, pkgInfo] of workspaceMap.entries()) {
1046
- const location = slash(pkgInfo.location);
1303
+ const location = chunk5TYVF4KJ_cjs.slash(pkgInfo.location);
1047
1304
  if (normalized.startsWith(location)) {
1048
1305
  importedFromPackages.add(pkgName);
1049
1306
  break;
@@ -1065,11 +1322,12 @@ async function buildExternalDependencies(virtualDependencies, {
1065
1322
  if (importedFromPackages.size === 1) {
1066
1323
  const [pkgName] = importedFromPackages;
1067
1324
  const workspaceLocation = workspaceMap.get(pkgName).location;
1068
- return prepareEntryFileName(getCompiledDepCachePath(workspaceLocation, "[name].mjs"), rootDir);
1325
+ return prepareEntryFileName(chunk5TYVF4KJ_cjs.getCompiledDepCachePath(workspaceLocation, "[name].mjs"), rootDir);
1069
1326
  }
1070
1327
  }
1071
1328
  return `${outputDirRelative}/[name].mjs`;
1072
1329
  },
1330
+ assetFileNames: `${outputDirRelative}/[name][extname]`,
1073
1331
  hoistTransitiveImports: false
1074
1332
  });
1075
1333
  await bundler.close();
@@ -1078,7 +1336,7 @@ async function buildExternalDependencies(virtualDependencies, {
1078
1336
  function findExternalImporter(module, external, allOutputs) {
1079
1337
  const capturedFiles = /* @__PURE__ */ new Set();
1080
1338
  for (const id of module.imports) {
1081
- if (id === external) {
1339
+ if (chunk5TYVF4KJ_cjs.isDependencyPartOfPackage(id, external)) {
1082
1340
  return module;
1083
1341
  } else {
1084
1342
  if (id.endsWith(".mjs")) {
@@ -1099,19 +1357,31 @@ function findExternalImporter(module, external, allOutputs) {
1099
1357
  }
1100
1358
  async function bundleExternals(depsToOptimize, outputDir, options) {
1101
1359
  const { workspaceRoot = null, workspaceMap = /* @__PURE__ */ new Map(), projectRoot = outputDir, bundlerOptions = {} } = options;
1102
- const {
1103
- externals: customExternals = [],
1104
- transpilePackages = [],
1105
- isDev = false} = bundlerOptions || {};
1106
- const allExternals = [...GLOBAL_EXTERNALS, ...DEPRECATED_EXTERNALS, ...customExternals];
1360
+ const { externals: customExternals = [], transpilePackages = [], isDev = false } = bundlerOptions || {};
1361
+ let externalsPreset = false;
1362
+ if (customExternals === true) {
1363
+ externalsPreset = true;
1364
+ }
1365
+ const externalsList = Array.isArray(customExternals) ? customExternals : [];
1366
+ const allExternals = [...GLOBAL_EXTERNALS, ...DEPRECATED_EXTERNALS, ...externalsList];
1107
1367
  const workspacePackagesNames = Array.from(workspaceMap.keys());
1108
1368
  const packagesToTranspile = /* @__PURE__ */ new Set([...transpilePackages, ...workspacePackagesNames]);
1369
+ const extractedExternals = /* @__PURE__ */ new Map();
1370
+ if (externalsPreset) {
1371
+ for (const [dep, metadata] of depsToOptimize.entries()) {
1372
+ if (!metadata.isWorkspace) {
1373
+ extractedExternals.set(dep, metadata.rootPath ?? dep);
1374
+ depsToOptimize.delete(dep);
1375
+ }
1376
+ }
1377
+ }
1109
1378
  const { optimizedDependencyEntries, fileNameToDependencyMap } = createVirtualDependencies(depsToOptimize, {
1110
1379
  workspaceRoot,
1111
1380
  outputDir,
1112
1381
  projectRoot,
1113
1382
  bundlerOptions: {
1114
- isDev
1383
+ isDev,
1384
+ externalsPreset
1115
1385
  }
1116
1386
  });
1117
1387
  const output = await buildExternalDependencies(optimizedDependencyEntries, {
@@ -1121,10 +1391,11 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
1121
1391
  rootDir: workspaceRoot || projectRoot,
1122
1392
  outputDir,
1123
1393
  bundlerOptions: {
1124
- isDev
1394
+ isDev,
1395
+ externalsPreset
1125
1396
  }
1126
1397
  });
1127
- const moduleResolveMap = /* @__PURE__ */ new Map();
1398
+ const moduleResolveMap2 = /* @__PURE__ */ new Map();
1128
1399
  const filteredChunks = output.filter((o) => o.type === "chunk");
1129
1400
  for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
1130
1401
  for (const external of allExternals) {
@@ -1134,10 +1405,10 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
1134
1405
  const importer = findExternalImporter(o, external, filteredChunks);
1135
1406
  if (importer) {
1136
1407
  const fullPath = path2__namespace.join(workspaceRoot || projectRoot, importer.fileName);
1137
- let innerMap = moduleResolveMap.get(fullPath);
1408
+ let innerMap = moduleResolveMap2.get(fullPath);
1138
1409
  if (!innerMap) {
1139
1410
  innerMap = /* @__PURE__ */ new Map();
1140
- moduleResolveMap.set(fullPath, innerMap);
1411
+ moduleResolveMap2.set(fullPath, innerMap);
1141
1412
  }
1142
1413
  if (importer.moduleIds.length) {
1143
1414
  innerMap.set(
@@ -1149,15 +1420,125 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
1149
1420
  }
1150
1421
  }
1151
1422
  const usedExternals = /* @__PURE__ */ Object.create(null);
1152
- for (const [fullPath, innerMap] of moduleResolveMap) {
1423
+ for (const [fullPath, innerMap] of moduleResolveMap2) {
1153
1424
  const innerObj = /* @__PURE__ */ Object.create(null);
1154
1425
  for (const [external, value] of innerMap) {
1155
1426
  innerObj[external] = value;
1156
1427
  }
1157
1428
  usedExternals[fullPath] = innerObj;
1158
1429
  }
1430
+ if (extractedExternals.size > 0) {
1431
+ const syntheticPath = path2__namespace.join(workspaceRoot || projectRoot, "__externals__");
1432
+ const externalsObj = /* @__PURE__ */ Object.create(null);
1433
+ for (const [dep, rootPath] of extractedExternals) {
1434
+ externalsObj[dep] = rootPath;
1435
+ }
1436
+ usedExternals[syntheticPath] = externalsObj;
1437
+ }
1159
1438
  return { output, fileNameToDependencyMap, usedExternals };
1160
1439
  }
1440
+
1441
+ // ../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js
1442
+ var UNKNOWN_FUNCTION = "<unknown>";
1443
+ function parse(stackString) {
1444
+ var lines = stackString.split("\n");
1445
+ return lines.reduce(function(stack, line) {
1446
+ var parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
1447
+ if (parseResult) {
1448
+ stack.push(parseResult);
1449
+ }
1450
+ return stack;
1451
+ }, []);
1452
+ }
1453
+ var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|rsc|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
1454
+ var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
1455
+ function parseChrome(line) {
1456
+ var parts = chromeRe.exec(line);
1457
+ if (!parts) {
1458
+ return null;
1459
+ }
1460
+ var isNative = parts[2] && parts[2].indexOf("native") === 0;
1461
+ var isEval = parts[2] && parts[2].indexOf("eval") === 0;
1462
+ var submatch = chromeEvalRe.exec(parts[2]);
1463
+ if (isEval && submatch != null) {
1464
+ parts[2] = submatch[1];
1465
+ parts[3] = submatch[2];
1466
+ parts[4] = submatch[3];
1467
+ }
1468
+ return {
1469
+ file: !isNative ? parts[2] : null,
1470
+ methodName: parts[1] || UNKNOWN_FUNCTION,
1471
+ arguments: isNative ? [parts[2]] : [],
1472
+ lineNumber: parts[3] ? +parts[3] : null,
1473
+ column: parts[4] ? +parts[4] : null
1474
+ };
1475
+ }
1476
+ var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|rsc|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
1477
+ function parseWinjs(line) {
1478
+ var parts = winjsRe.exec(line);
1479
+ if (!parts) {
1480
+ return null;
1481
+ }
1482
+ return {
1483
+ file: parts[2],
1484
+ methodName: parts[1] || UNKNOWN_FUNCTION,
1485
+ arguments: [],
1486
+ lineNumber: +parts[3],
1487
+ column: parts[4] ? +parts[4] : null
1488
+ };
1489
+ }
1490
+ var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|rsc|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
1491
+ var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
1492
+ function parseGecko(line) {
1493
+ var parts = geckoRe.exec(line);
1494
+ if (!parts) {
1495
+ return null;
1496
+ }
1497
+ var isEval = parts[3] && parts[3].indexOf(" > eval") > -1;
1498
+ var submatch = geckoEvalRe.exec(parts[3]);
1499
+ if (isEval && submatch != null) {
1500
+ parts[3] = submatch[1];
1501
+ parts[4] = submatch[2];
1502
+ parts[5] = null;
1503
+ }
1504
+ return {
1505
+ file: parts[3],
1506
+ methodName: parts[1] || UNKNOWN_FUNCTION,
1507
+ arguments: parts[2] ? parts[2].split(",") : [],
1508
+ lineNumber: parts[4] ? +parts[4] : null,
1509
+ column: parts[5] ? +parts[5] : null
1510
+ };
1511
+ }
1512
+ var javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
1513
+ function parseJSC(line) {
1514
+ var parts = javaScriptCoreRe.exec(line);
1515
+ if (!parts) {
1516
+ return null;
1517
+ }
1518
+ return {
1519
+ file: parts[3],
1520
+ methodName: parts[1] || UNKNOWN_FUNCTION,
1521
+ arguments: [],
1522
+ lineNumber: +parts[4],
1523
+ column: parts[5] ? +parts[5] : null
1524
+ };
1525
+ }
1526
+ var nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
1527
+ function parseNode(line) {
1528
+ var parts = nodeRe.exec(line);
1529
+ if (!parts) {
1530
+ return null;
1531
+ }
1532
+ return {
1533
+ file: parts[2],
1534
+ methodName: parts[1] || UNKNOWN_FUNCTION,
1535
+ arguments: [],
1536
+ lineNumber: +parts[3],
1537
+ column: parts[4] ? +parts[4] : null
1538
+ };
1539
+ }
1540
+
1541
+ // src/build/analyze.ts
1161
1542
  function throwExternalDependencyError({
1162
1543
  errorId,
1163
1544
  moduleName,
@@ -1181,73 +1562,152 @@ export const mastra = new Mastra({
1181
1562
  })`
1182
1563
  });
1183
1564
  }
1565
+ function getPackageNameFromBundledModuleName(moduleName) {
1566
+ const chunks = moduleName.split("-");
1567
+ if (!chunks.length) {
1568
+ return moduleName;
1569
+ }
1570
+ if (chunks[0]?.startsWith("@")) {
1571
+ return chunks.slice(0, 2).join("/");
1572
+ }
1573
+ return chunks[0];
1574
+ }
1575
+ function validateError(err, file, {
1576
+ binaryMapData,
1577
+ workspaceMap
1578
+ }) {
1579
+ let moduleName = null;
1580
+ let errorConfig = null;
1581
+ if (err instanceof ValidationError) {
1582
+ const parsedStack = parse(err.stack);
1583
+ if (err.type === "TypeError") {
1584
+ const pkgNameRegex = /.*node_modules\/([^\/]+)\//;
1585
+ const stacktraceFrame = parsedStack.find((frame) => frame.file && pkgNameRegex.test(frame.file));
1586
+ if (stacktraceFrame) {
1587
+ const match = stacktraceFrame.file.match(pkgNameRegex);
1588
+ moduleName = match?.[1] ?? getPackageNameFromBundledModuleName(path2.basename(file.name));
1589
+ } else {
1590
+ moduleName = getPackageNameFromBundledModuleName(path2.basename(file.name));
1591
+ }
1592
+ errorConfig = {
1593
+ id: "DEPLOYER_ANALYZE_TYPE_ERROR",
1594
+ messagePrefix: `Mastra wasn't able to bundle "${moduleName}", might be an older commonJS module. Please add`
1595
+ };
1596
+ } else if (err.stack?.includes?.("[ERR_MODULE_NOT_FOUND]")) {
1597
+ moduleName = err.message.match(/Cannot find package '([^']+)'/)?.[1];
1598
+ const parentModuleName = getPackageNameFromBundledModuleName(path2.basename(file.name));
1599
+ errorConfig = {
1600
+ id: "DEPLOYER_ANALYZE_MODULE_NOT_FOUND",
1601
+ messagePrefix: `Mastra wasn't able to build your project, We couldn't load "${moduleName}" from "${parentModuleName}". Make sure "${moduleName}" is installed or add`
1602
+ };
1603
+ if (moduleName === parentModuleName) {
1604
+ return;
1605
+ }
1606
+ }
1607
+ }
1608
+ if (err.message.includes("No native build was found")) {
1609
+ const pkgName = getPackageNameFromBundledModuleName(path2.basename(file.name));
1610
+ moduleName = binaryMapData[file.fileName]?.[0] ?? pkgName;
1611
+ errorConfig = {
1612
+ id: "DEPLOYER_ANALYZE_MISSING_NATIVE_BUILD",
1613
+ messagePrefix: "We found a binary dependency in your bundle but we cannot bundle it yet. Please add"
1614
+ };
1615
+ }
1616
+ if (moduleName && workspaceMap.has(moduleName)) {
1617
+ throw new error.MastraError({
1618
+ id: "DEPLOYER_ANALYZE_ERROR_IN_WORKSPACE",
1619
+ domain: error.ErrorDomain.DEPLOYER,
1620
+ category: error.ErrorCategory.USER,
1621
+ details: {
1622
+ // importFile: moduleName,
1623
+ packageName: moduleName
1624
+ },
1625
+ text: `We found an error in the ${moduleName} workspace package. Please find the offending package and fix the error.
1626
+ Error: ${err.stack}`
1627
+ });
1628
+ }
1629
+ if (errorConfig && moduleName) {
1630
+ throwExternalDependencyError({
1631
+ errorId: errorConfig.id,
1632
+ moduleName,
1633
+ packageName: moduleName,
1634
+ messagePrefix: errorConfig.messagePrefix
1635
+ });
1636
+ }
1637
+ }
1638
+ async function validateFile(root, file, {
1639
+ binaryMapData,
1640
+ moduleResolveMapLocation,
1641
+ logger,
1642
+ workspaceMap
1643
+ }) {
1644
+ try {
1645
+ if (!file.isDynamicEntry && file.isEntry) {
1646
+ await validate(path2.join(root, file.fileName), {
1647
+ moduleResolveMapLocation,
1648
+ injectESMShim: false
1649
+ });
1650
+ }
1651
+ } catch (err) {
1652
+ let errorToHandle = err;
1653
+ if (err instanceof ValidationError && err.type === "ReferenceError" && (err.message.startsWith("__dirname") || err.message.startsWith("__filename"))) {
1654
+ try {
1655
+ await validate(path2.join(root, file.fileName), {
1656
+ moduleResolveMapLocation,
1657
+ injectESMShim: true
1658
+ });
1659
+ errorToHandle = null;
1660
+ } catch (err2) {
1661
+ errorToHandle = err2;
1662
+ }
1663
+ }
1664
+ if (errorToHandle instanceof Error) {
1665
+ validateError(errorToHandle, file, { binaryMapData, workspaceMap });
1666
+ }
1667
+ }
1668
+ }
1184
1669
  async function validateOutput({
1185
1670
  output,
1186
1671
  reverseVirtualReferenceMap,
1187
1672
  usedExternals,
1188
1673
  outputDir,
1189
1674
  projectRoot,
1190
- workspaceMap
1675
+ workspaceMap,
1676
+ depsVersionInfo
1191
1677
  }, logger) {
1192
1678
  const result = {
1193
1679
  dependencies: /* @__PURE__ */ new Map(),
1194
- externalDependencies: /* @__PURE__ */ new Set(),
1680
+ externalDependencies: /* @__PURE__ */ new Map(),
1195
1681
  workspaceMap
1196
1682
  };
1197
- await promises.writeFile(path2.join(outputDir, "module-resolve-map.json"), JSON.stringify(usedExternals, null, 2));
1198
1683
  for (const deps of Object.values(usedExternals)) {
1199
1684
  for (const dep of Object.keys(deps)) {
1200
- result.externalDependencies.add(dep);
1685
+ const pkgName = chunk5TYVF4KJ_cjs.getPackageName(dep);
1686
+ if (pkgName) {
1687
+ const versionInfo = depsVersionInfo.get(dep) || depsVersionInfo.get(pkgName) || {};
1688
+ result.externalDependencies.set(pkgName, versionInfo);
1689
+ }
1201
1690
  }
1202
1691
  }
1692
+ let binaryMapData = {};
1693
+ if (fs.existsSync(path2.join(outputDir, "binary-map.json"))) {
1694
+ const binaryMap = await promises.readFile(path2.join(outputDir, "binary-map.json"), "utf-8");
1695
+ binaryMapData = JSON.parse(binaryMap);
1696
+ }
1203
1697
  for (const file of output) {
1204
1698
  if (file.type === "asset") {
1205
1699
  continue;
1206
1700
  }
1207
- try {
1208
- logger.debug(`Validating if ${file.fileName} is a valid module.`);
1209
- if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
1210
- result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
1211
- }
1212
- if (!file.isDynamicEntry && file.isEntry) {
1213
- await validate(path2.join(projectRoot, file.fileName));
1214
- }
1215
- } catch (err) {
1216
- if (err instanceof Error) {
1217
- let moduleName = null;
1218
- let errorConfig = null;
1219
- if (err.message.includes("[ERR_MODULE_NOT_FOUND]")) {
1220
- const moduleIdName = file.moduleIds.length >= 2 ? file.moduleIds[file.moduleIds.length - 2] : void 0;
1221
- const fallbackName = file.name.split("/").pop();
1222
- moduleName = moduleIdName ?? fallbackName;
1223
- errorConfig = {
1224
- id: "DEPLOYER_ANALYZE_MODULE_NOT_FOUND",
1225
- messagePrefix: "Mastra wasn't able to build your project. Please add"
1226
- };
1227
- } else if (err.message.includes("Error: No native build was found for ")) {
1228
- moduleName = findNativePackageModule(file.moduleIds);
1229
- errorConfig = {
1230
- id: "DEPLOYER_ANALYZE_MISSING_NATIVE_BUILD",
1231
- messagePrefix: "We found a binary dependency in your bundle. Please add"
1232
- };
1233
- }
1234
- if (moduleName && errorConfig) {
1235
- const pkgInfo = await localPkg.getPackageInfo(moduleName);
1236
- const packageName = pkgInfo?.packageJson?.name;
1237
- if (packageName) {
1238
- throwExternalDependencyError({
1239
- errorId: errorConfig.id,
1240
- moduleName,
1241
- packageName,
1242
- messagePrefix: errorConfig.messagePrefix
1243
- });
1244
- } else {
1245
- logger.debug(`Could not determine the module name for file ${file.fileName}`);
1246
- }
1247
- }
1248
- logger.debug(`Error while validating module ${file.fileName}: ${err.message}`);
1249
- }
1701
+ logger.debug(`Validating if ${file.fileName} is a valid module.`);
1702
+ if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
1703
+ result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
1250
1704
  }
1705
+ await validateFile(projectRoot, file, {
1706
+ binaryMapData,
1707
+ moduleResolveMapLocation: path2.join(outputDir, "module-resolve-map.json"),
1708
+ logger,
1709
+ workspaceMap
1710
+ });
1251
1711
  }
1252
1712
  return result;
1253
1713
  }
@@ -1255,7 +1715,7 @@ async function analyzeBundle(entries, mastraEntry, {
1255
1715
  outputDir,
1256
1716
  projectRoot,
1257
1717
  isDev = false,
1258
- bundlerOptions: _bundlerOptions
1718
+ bundlerOptions
1259
1719
  }, logger) {
1260
1720
  const mastraConfig = await promises.readFile(mastraEntry, "utf-8");
1261
1721
  const mastraConfigResult = {
@@ -1274,22 +1734,38 @@ export const mastra = new Mastra({
1274
1734
 
1275
1735
  If you think your configuration is valid, please open an issue.`);
1276
1736
  }
1277
- const { enableEsmShim = true } = _bundlerOptions || {};
1278
- const bundlerOptions = await getBundlerOptions(mastraEntry, outputDir);
1279
1737
  const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: mastraEntry });
1738
+ let externalsPreset = false;
1739
+ const userExternals = Array.isArray(bundlerOptions?.externals) ? bundlerOptions?.externals : [];
1740
+ if (bundlerOptions?.externals === true) {
1741
+ externalsPreset = true;
1742
+ }
1280
1743
  let index = 0;
1281
1744
  const depsToOptimize = /* @__PURE__ */ new Map();
1745
+ const allExternals = [...GLOBAL_EXTERNALS, ...userExternals].filter(Boolean);
1282
1746
  logger.info("Analyzing dependencies...");
1747
+ const allUsedExternals = /* @__PURE__ */ new Map();
1283
1748
  for (const entry of entries) {
1284
1749
  const isVirtualFile = entry.includes("\n") || !fs.existsSync(entry);
1285
1750
  const analyzeResult = await analyzeEntry({ entry, isVirtualFile }, mastraEntry, {
1286
1751
  logger,
1287
- sourcemapEnabled: bundlerOptions?.sourcemap ?? false,
1752
+ sourcemapEnabled: bundlerOptions?.enableSourcemap ?? false,
1288
1753
  workspaceMap,
1289
- projectRoot
1754
+ projectRoot,
1755
+ shouldCheckTransitiveDependencies: isDev || externalsPreset
1290
1756
  });
1291
1757
  await promises.writeFile(path2.join(outputDir, `entry-${index++}.mjs`), analyzeResult.output.code);
1292
1758
  for (const [dep, metadata] of analyzeResult.dependencies.entries()) {
1759
+ const isPartOfExternals = allExternals.some((external) => chunk5TYVF4KJ_cjs.isDependencyPartOfPackage(dep, external));
1760
+ if (isPartOfExternals || externalsPreset && !metadata.isWorkspace) {
1761
+ const pkgName = chunk5TYVF4KJ_cjs.getPackageName(dep);
1762
+ if (pkgName && !allUsedExternals.has(pkgName)) {
1763
+ allUsedExternals.set(pkgName, {
1764
+ version: metadata.version
1765
+ });
1766
+ }
1767
+ continue;
1768
+ }
1293
1769
  if (depsToOptimize.has(dep)) {
1294
1770
  const existingEntry = depsToOptimize.get(dep);
1295
1771
  depsToOptimize.set(dep, {
@@ -1301,28 +1777,64 @@ If you think your configuration is valid, please open an issue.`);
1301
1777
  }
1302
1778
  }
1303
1779
  }
1304
- if (isDev) {
1780
+ if (isDev || externalsPreset) {
1305
1781
  for (const [dep, metadata] of depsToOptimize.entries()) {
1306
1782
  if (!metadata.isWorkspace) {
1307
1783
  depsToOptimize.delete(dep);
1308
1784
  }
1309
1785
  }
1310
1786
  }
1311
- logger.debug(`Analyzed dependencies: ${Array.from(depsToOptimize.keys()).join(", ")}`);
1787
+ const sortedDeps = Array.from(depsToOptimize.keys()).sort();
1312
1788
  logger.info("Optimizing dependencies...");
1313
- logger.debug(
1314
- `${Array.from(depsToOptimize.keys()).map((key) => `- ${key}`).join("\n")}`
1315
- );
1789
+ logger.debug(`${sortedDeps.map((key) => `- ${key}`).join("\n")}`);
1316
1790
  const { output, fileNameToDependencyMap, usedExternals } = await bundleExternals(depsToOptimize, outputDir, {
1317
1791
  bundlerOptions: {
1318
1792
  ...bundlerOptions,
1319
- enableEsmShim,
1793
+ externals: bundlerOptions?.externals ?? allExternals,
1320
1794
  isDev
1321
1795
  },
1322
1796
  projectRoot,
1323
1797
  workspaceRoot,
1324
1798
  workspaceMap
1325
1799
  });
1800
+ const relativeWorkspaceFolderPaths = Array.from(workspaceMap.values()).map(
1801
+ (pkgInfo) => path2.relative(workspaceRoot || projectRoot, pkgInfo.location)
1802
+ );
1803
+ const depsVersionInfo = /* @__PURE__ */ new Map();
1804
+ for (const [dep, metadata] of depsToOptimize.entries()) {
1805
+ const pkgName = chunk5TYVF4KJ_cjs.getPackageName(dep);
1806
+ if (pkgName && metadata.version) {
1807
+ depsVersionInfo.set(pkgName, {
1808
+ version: metadata.version
1809
+ });
1810
+ }
1811
+ if (metadata.version) {
1812
+ depsVersionInfo.set(dep, {
1813
+ version: metadata.version
1814
+ });
1815
+ }
1816
+ }
1817
+ for (const o of output) {
1818
+ if (o.type === "asset") {
1819
+ continue;
1820
+ }
1821
+ for (const i of o.imports) {
1822
+ if (chunk5TYVF4KJ_cjs.isBuiltinModule(i)) {
1823
+ continue;
1824
+ }
1825
+ if (i.startsWith(".") || i.startsWith("/")) {
1826
+ continue;
1827
+ }
1828
+ if (relativeWorkspaceFolderPaths.some((workspacePath) => i.startsWith(workspacePath))) {
1829
+ continue;
1830
+ }
1831
+ const pkgName = chunk5TYVF4KJ_cjs.getPackageName(i);
1832
+ if (pkgName && !allUsedExternals.has(pkgName)) {
1833
+ const versionInfo = depsVersionInfo.get(i) || depsVersionInfo.get(pkgName) || {};
1834
+ allUsedExternals.set(pkgName, versionInfo);
1835
+ }
1836
+ }
1837
+ }
1326
1838
  const result = await validateOutput(
1327
1839
  {
1328
1840
  output,
@@ -1330,24 +1842,33 @@ If you think your configuration is valid, please open an issue.`);
1330
1842
  usedExternals,
1331
1843
  outputDir,
1332
1844
  projectRoot: workspaceRoot || projectRoot,
1333
- workspaceMap
1845
+ workspaceMap,
1846
+ depsVersionInfo
1334
1847
  },
1335
1848
  logger
1336
1849
  );
1337
- return result;
1850
+ const mergedExternalDeps = new Map(result.externalDependencies);
1851
+ for (const [dep, info] of allUsedExternals) {
1852
+ if (!mergedExternalDeps.has(dep)) {
1853
+ mergedExternalDeps.set(dep, info);
1854
+ }
1855
+ }
1856
+ return {
1857
+ ...result,
1858
+ externalDependencies: mergedExternalDeps
1859
+ };
1338
1860
  }
1339
1861
 
1340
1862
  exports.aliasHono = aliasHono;
1341
1863
  exports.analyzeBundle = analyzeBundle;
1342
1864
  exports.esbuild = esbuild;
1865
+ exports.esmShim = esmShim;
1343
1866
  exports.extractMastraOption = extractMastraOption;
1344
1867
  exports.getBundlerOptions = getBundlerOptions;
1345
- exports.getPackageName = getPackageName;
1346
1868
  exports.getPackageRootPath = getPackageRootPath;
1347
1869
  exports.getWorkspaceInformation = getWorkspaceInformation;
1348
- exports.removeAllOptionsFromMastraExcept = removeAllOptionsFromMastraExcept;
1349
1870
  exports.removeDeployer = removeDeployer2;
1350
- exports.slash = slash;
1871
+ exports.subpathExternalsResolver = subpathExternalsResolver;
1351
1872
  exports.tsConfigPaths = tsConfigPaths;
1352
- //# sourceMappingURL=chunk-JCACPNJQ.cjs.map
1353
- //# sourceMappingURL=chunk-JCACPNJQ.cjs.map
1873
+ //# sourceMappingURL=chunk-AS55XT3Y.cjs.map
1874
+ //# sourceMappingURL=chunk-AS55XT3Y.cjs.map