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

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 (136) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/arktype-aI7TBD0R-CCZH3EYK.js +8 -0
  3. package/dist/{arktype-aI7TBD0R-OEPFT4G6.js.map → arktype-aI7TBD0R-CCZH3EYK.js.map} +1 -1
  4. package/dist/{arktype-aI7TBD0R-4YXBEQBG.cjs → arktype-aI7TBD0R-XHBHUL3T.cjs} +3 -3
  5. package/dist/{arktype-aI7TBD0R-4YXBEQBG.cjs.map → arktype-aI7TBD0R-XHBHUL3T.cjs.map} +1 -1
  6. package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
  7. package/dist/build/analyze.cjs +2 -2
  8. package/dist/build/analyze.d.ts +3 -4
  9. package/dist/build/analyze.d.ts.map +1 -1
  10. package/dist/build/analyze.js +1 -1
  11. package/dist/build/babel/remove-deployer.d.ts.map +1 -1
  12. package/dist/build/bundler.cjs +3 -3
  13. package/dist/build/bundler.d.ts.map +1 -1
  14. package/dist/build/bundler.js +1 -1
  15. package/dist/build/bundlerOptions.d.ts.map +1 -1
  16. package/dist/build/deployer.d.ts.map +1 -1
  17. package/dist/build/index.cjs +10 -10
  18. package/dist/build/index.js +3 -3
  19. package/dist/build/plugins/node-modules-extension-resolver.d.ts.map +1 -1
  20. package/dist/build/plugins/remove-all-except.d.ts +10 -0
  21. package/dist/build/plugins/remove-all-except.d.ts.map +1 -0
  22. package/dist/build/serverOptions.d.ts.map +1 -1
  23. package/dist/build/shared/extract-mastra-option.d.ts +4 -8
  24. package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
  25. package/dist/build/types.d.ts +5 -0
  26. package/dist/build/types.d.ts.map +1 -1
  27. package/dist/bundler/index.cjs +6 -2
  28. package/dist/bundler/index.d.ts +7 -7
  29. package/dist/bundler/index.d.ts.map +1 -1
  30. package/dist/bundler/index.js +1 -1
  31. package/dist/chunk-2VG357HT.cjs +4 -0
  32. package/dist/{chunk-BTNPI4Z7.cjs.map → chunk-2VG357HT.cjs.map} +1 -1
  33. package/dist/chunk-4P2LYC33.js +14 -0
  34. package/dist/{chunk-N5TMJUIR.js.map → chunk-4P2LYC33.js.map} +1 -1
  35. package/dist/chunk-54PQDTM3.cjs +16 -0
  36. package/dist/{chunk-ID3HN3BH.cjs.map → chunk-54PQDTM3.cjs.map} +1 -1
  37. package/dist/{chunk-MMUE22EL.js → chunk-5HTKP372.js} +9 -9
  38. package/dist/{chunk-MMUE22EL.js.map → chunk-5HTKP372.js.map} +1 -1
  39. package/dist/{chunk-3GOE3SL2.cjs → chunk-7F6JKGX4.cjs} +48 -33
  40. package/dist/chunk-7F6JKGX4.cjs.map +1 -0
  41. package/dist/{chunk-RGUNHE4Y.js → chunk-BDA7RMRF.js} +198 -181
  42. package/dist/chunk-BDA7RMRF.js.map +1 -0
  43. package/dist/{chunk-KCGBR2X6.cjs → chunk-CRIOGWZD.cjs} +197 -181
  44. package/dist/chunk-CRIOGWZD.cjs.map +1 -0
  45. package/dist/{chunk-TXKETRIN.cjs → chunk-DMISJICL.cjs} +9 -9
  46. package/dist/{chunk-TXKETRIN.cjs.map → chunk-DMISJICL.cjs.map} +1 -1
  47. package/dist/{chunk-XTXGU6QF.js → chunk-ESR6AK5N.js} +43 -29
  48. package/dist/chunk-ESR6AK5N.js.map +1 -0
  49. package/dist/chunk-G6GFAPPU.js +6 -0
  50. package/dist/{chunk-Q2YGWEXY.js.map → chunk-G6GFAPPU.js.map} +1 -1
  51. package/dist/chunk-HPGDVJAZ.js +3 -0
  52. package/dist/{chunk-FBT6QP7J.js.map → chunk-HPGDVJAZ.js.map} +1 -1
  53. package/dist/{chunk-24GY667C.cjs → chunk-HRCR6OKC.cjs} +11 -22
  54. package/dist/chunk-HRCR6OKC.cjs.map +1 -0
  55. package/dist/{chunk-GD2TGMBP.cjs → chunk-JBE6KM7R.cjs} +3 -3
  56. package/dist/{chunk-GD2TGMBP.cjs.map → chunk-JBE6KM7R.cjs.map} +1 -1
  57. package/dist/{chunk-7PLNIFGZ.cjs → chunk-KE4NVPI4.cjs} +3 -3
  58. package/dist/{chunk-7PLNIFGZ.cjs.map → chunk-KE4NVPI4.cjs.map} +1 -1
  59. package/dist/{chunk-R6O3XWXM.js → chunk-ONWHS3PA.js} +34 -79
  60. package/dist/chunk-ONWHS3PA.js.map +1 -0
  61. package/dist/{chunk-LENVOSFH.cjs → chunk-OVVUJ46G.cjs} +39 -85
  62. package/dist/chunk-OVVUJ46G.cjs.map +1 -0
  63. package/dist/{chunk-P4L6VIHY.js → chunk-V4HCIN6G.js} +3 -3
  64. package/dist/{chunk-P4L6VIHY.js.map → chunk-V4HCIN6G.js.map} +1 -1
  65. package/dist/{chunk-SRPOHKWH.js → chunk-WFIG7I5C.js} +5 -16
  66. package/dist/chunk-WFIG7I5C.js.map +1 -0
  67. package/dist/default-u_dwuiYb-IKALPRLV.js +3 -0
  68. package/dist/{default-u_dwuiYb-65M4BHAA.js.map → default-u_dwuiYb-IKALPRLV.js.map} +1 -1
  69. package/dist/default-u_dwuiYb-ZNEZWEPC.cjs +9 -0
  70. package/dist/{default-u_dwuiYb-PWN6FHC6.cjs.map → default-u_dwuiYb-ZNEZWEPC.cjs.map} +1 -1
  71. package/dist/effect-QlVUlMFu-2KN4AWBH.cjs +17 -0
  72. package/dist/{effect-QlVUlMFu-2ADPKIDF.cjs.map → effect-QlVUlMFu-2KN4AWBH.cjs.map} +1 -1
  73. package/dist/{effect-QlVUlMFu-FD73M3OO.js → effect-QlVUlMFu-MWXQUT6S.js} +4 -4
  74. package/dist/{effect-QlVUlMFu-FD73M3OO.js.map → effect-QlVUlMFu-MWXQUT6S.js.map} +1 -1
  75. package/dist/index.cjs +4 -15
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.js +3 -14
  78. package/dist/index.js.map +1 -1
  79. package/dist/server/index.cjs +263 -15
  80. package/dist/server/index.cjs.map +1 -1
  81. package/dist/server/index.d.ts.map +1 -1
  82. package/dist/server/index.js +261 -13
  83. package/dist/server/index.js.map +1 -1
  84. package/dist/sury-CWZTCd75-6QYFZXZY.cjs +17 -0
  85. package/dist/{sury-CWZTCd75-K3FHMZF5.cjs.map → sury-CWZTCd75-6QYFZXZY.cjs.map} +1 -1
  86. package/dist/{sury-CWZTCd75-Y2GURJ6K.js → sury-CWZTCd75-DAPFEZIA.js} +4 -4
  87. package/dist/{sury-CWZTCd75-Y2GURJ6K.js.map → sury-CWZTCd75-DAPFEZIA.js.map} +1 -1
  88. package/dist/typebox-Dei93FPO-LBLFC3RD.js +8 -0
  89. package/dist/{typebox-Dei93FPO-2WP4NOYD.js.map → typebox-Dei93FPO-LBLFC3RD.js.map} +1 -1
  90. package/dist/{typebox-Dei93FPO-WTXAW2LA.cjs → typebox-Dei93FPO-RDSW6DFA.cjs} +3 -3
  91. package/dist/{typebox-Dei93FPO-WTXAW2LA.cjs.map → typebox-Dei93FPO-RDSW6DFA.cjs.map} +1 -1
  92. package/dist/{valibot--1zFm7rT-VGFBTDTW.js → valibot--1zFm7rT-AASENK42.js} +4 -4
  93. package/dist/{valibot--1zFm7rT-VGFBTDTW.js.map → valibot--1zFm7rT-AASENK42.js.map} +1 -1
  94. package/dist/valibot--1zFm7rT-OOWNQW47.cjs +17 -0
  95. package/dist/{valibot--1zFm7rT-HMTCRBB3.cjs.map → valibot--1zFm7rT-OOWNQW47.cjs.map} +1 -1
  96. package/dist/{valibot-D_HTw1Gn-ILCWWLE4.cjs → valibot-D_HTw1Gn-PBXMZJWR.cjs} +7 -7
  97. package/dist/{valibot-D_HTw1Gn-ILCWWLE4.cjs.map → valibot-D_HTw1Gn-PBXMZJWR.cjs.map} +1 -1
  98. package/dist/{valibot-D_HTw1Gn-LLCGNU3W.js → valibot-D_HTw1Gn-PCY2UTIB.js} +5 -5
  99. package/dist/{valibot-D_HTw1Gn-LLCGNU3W.js.map → valibot-D_HTw1Gn-PCY2UTIB.js.map} +1 -1
  100. package/dist/{zod-Bwrt9trS-XCRGYQVE.js → zod-Bwrt9trS-MTR3E2QO.js} +4 -4
  101. package/dist/{zod-Bwrt9trS-XCRGYQVE.js.map → zod-Bwrt9trS-MTR3E2QO.js.map} +1 -1
  102. package/dist/{zod-Bwrt9trS-XDMWF3NW.cjs → zod-Bwrt9trS-OXQA54TZ.cjs} +6 -6
  103. package/dist/{zod-Bwrt9trS-XDMWF3NW.cjs.map → zod-Bwrt9trS-OXQA54TZ.cjs.map} +1 -1
  104. package/dist/{zod-DSgpEGAE-ZWQMF6SS.cjs → zod-DSgpEGAE-7BIIMWZW.cjs} +7 -7
  105. package/dist/{zod-DSgpEGAE-ZWQMF6SS.cjs.map → zod-DSgpEGAE-7BIIMWZW.cjs.map} +1 -1
  106. package/dist/{zod-DSgpEGAE-TKBHSSLS.js → zod-DSgpEGAE-UO7OP3J6.js} +5 -5
  107. package/dist/{zod-DSgpEGAE-TKBHSSLS.js.map → zod-DSgpEGAE-UO7OP3J6.js.map} +1 -1
  108. package/package.json +6 -6
  109. package/dist/arktype-aI7TBD0R-OEPFT4G6.js +0 -8
  110. package/dist/build/babel/get-deployer.d.ts +0 -3
  111. package/dist/build/babel/get-deployer.d.ts.map +0 -1
  112. package/dist/build/babel/remove-all-options-bundler.d.ts +0 -5
  113. package/dist/build/babel/remove-all-options-bundler.d.ts.map +0 -1
  114. package/dist/build/babel/remove-all-options-deployer.d.ts +0 -5
  115. package/dist/build/babel/remove-all-options-deployer.d.ts.map +0 -1
  116. package/dist/build/babel/remove-all-options-server.d.ts +0 -5
  117. package/dist/build/babel/remove-all-options-server.d.ts.map +0 -1
  118. package/dist/chunk-24GY667C.cjs.map +0 -1
  119. package/dist/chunk-3GOE3SL2.cjs.map +0 -1
  120. package/dist/chunk-BTNPI4Z7.cjs +0 -4
  121. package/dist/chunk-FBT6QP7J.js +0 -3
  122. package/dist/chunk-ID3HN3BH.cjs +0 -16
  123. package/dist/chunk-KCGBR2X6.cjs.map +0 -1
  124. package/dist/chunk-LENVOSFH.cjs.map +0 -1
  125. package/dist/chunk-N5TMJUIR.js +0 -14
  126. package/dist/chunk-Q2YGWEXY.js +0 -6
  127. package/dist/chunk-R6O3XWXM.js.map +0 -1
  128. package/dist/chunk-RGUNHE4Y.js.map +0 -1
  129. package/dist/chunk-SRPOHKWH.js.map +0 -1
  130. package/dist/chunk-XTXGU6QF.js.map +0 -1
  131. package/dist/default-u_dwuiYb-65M4BHAA.js +0 -3
  132. package/dist/default-u_dwuiYb-PWN6FHC6.cjs +0 -9
  133. package/dist/effect-QlVUlMFu-2ADPKIDF.cjs +0 -17
  134. package/dist/sury-CWZTCd75-K3FHMZF5.cjs +0 -17
  135. package/dist/typebox-Dei93FPO-2WP4NOYD.js +0 -8
  136. package/dist/valibot--1zFm7rT-HMTCRBB3.cjs +0 -17
@@ -143,87 +143,6 @@ globalThis.__dirname = dirname(__filename);
143
143
  }
144
144
  );
145
145
  }
146
- function removeAllOptionsFromMastraExcept(result, option, logger) {
147
- const t = babel__namespace.default.types;
148
- return {
149
- name: "remove-all-except-" + option + "-config",
150
- visitor: {
151
- ExportNamedDeclaration: {
152
- // remove all exports
153
- exit(path3) {
154
- path3.remove();
155
- }
156
- },
157
- NewExpression(path3, state) {
158
- const varDeclaratorPath = path3.findParent((path4) => t.isVariableDeclarator(path4.node));
159
- if (!varDeclaratorPath) {
160
- return;
161
- }
162
- const parentNode = path3.parentPath.node;
163
- if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
164
- return;
165
- }
166
- let mastraArgs = t.objectExpression([]);
167
- if (t.isObjectExpression(path3.node.arguments[0])) {
168
- mastraArgs = path3.node.arguments[0];
169
- }
170
- let configProperty = mastraArgs.properties.find(
171
- // @ts-ignore
172
- (prop) => prop.key.name === option
173
- );
174
- let configValue = t.objectExpression([]);
175
- const programPath = path3.scope.getProgramParent().path;
176
- if (!programPath) {
177
- return;
178
- }
179
- if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {
180
- result.hasCustomConfig = true;
181
- configValue = configProperty.value;
182
- if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {
183
- const configBinding = state.file.scope.getBinding(option);
184
- if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {
185
- const id = path3.scope.generateUidIdentifier(option);
186
- configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init));
187
- configValue = id;
188
- }
189
- }
190
- }
191
- const exportDeclaration = t.exportNamedDeclaration(
192
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]),
193
- []
194
- );
195
- programPath.node.body.push(exportDeclaration);
196
- },
197
- Program: {
198
- exit(path3) {
199
- const hasExport = path3.node.body.some(
200
- (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
201
- );
202
- if (!hasExport) {
203
- if (logger) {
204
- logger.warn(`Mastra ${option} config could not be extracted. Please make sure your entry file looks like this:
205
- export const mastra = new Mastra({
206
- ${option}: <value>
207
- })
208
-
209
- `);
210
- }
211
- const fallbackExportDeclaration = t.exportNamedDeclaration(
212
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
213
- []
214
- );
215
- path3.node.body.push(fallbackExportDeclaration);
216
- }
217
- }
218
- }
219
- }
220
- };
221
- }
222
-
223
- // src/build/babel/remove-all-options-bundler.ts
224
- function removeAllOptionsExceptBundler(result, logger) {
225
- return removeAllOptionsFromMastraExcept(result, "bundler", logger);
226
- }
227
146
  function esbuild(options = {}) {
228
147
  return originalEsbuild__default.default({
229
148
  target: "node20",
@@ -441,7 +360,117 @@ function recursiveRemoveNonReferencedNodes(code) {
441
360
  );
442
361
  });
443
362
  }
444
- function extractMastraOptionBundler(name, entryFile, transformer, result, logger) {
363
+ function removeAllOptionsFromMastraExcept(result, option, logger) {
364
+ const t = babel__namespace.default.types;
365
+ return {
366
+ name: "remove-all-except-" + option + "-config",
367
+ visitor: {
368
+ ExportNamedDeclaration: {
369
+ // remove all exports
370
+ exit(path3) {
371
+ path3.remove();
372
+ }
373
+ },
374
+ NewExpression(path3, state) {
375
+ const varDeclaratorPath = path3.findParent((path4) => t.isVariableDeclarator(path4.node));
376
+ if (!varDeclaratorPath) {
377
+ return;
378
+ }
379
+ const parentNode = path3.parentPath.node;
380
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
381
+ return;
382
+ }
383
+ let mastraArgs = t.objectExpression([]);
384
+ if (t.isObjectExpression(path3.node.arguments[0])) {
385
+ mastraArgs = path3.node.arguments[0];
386
+ }
387
+ let configProperty = mastraArgs.properties.find(
388
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option
389
+ );
390
+ let configValue = t.objectExpression([]);
391
+ const programPath = path3.scope.getProgramParent().path;
392
+ if (!programPath) {
393
+ return;
394
+ }
395
+ if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {
396
+ result.hasCustomConfig = true;
397
+ configValue = configProperty.value;
398
+ if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {
399
+ const configBinding = state.file.scope.getBinding(option);
400
+ if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {
401
+ const id = path3.scope.generateUidIdentifier(option);
402
+ configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init));
403
+ configValue = id;
404
+ }
405
+ }
406
+ }
407
+ const exportDeclaration = t.exportNamedDeclaration(
408
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]),
409
+ []
410
+ );
411
+ programPath.node.body.push(exportDeclaration);
412
+ },
413
+ Program: {
414
+ exit(path3) {
415
+ const hasExport = path3.node.body.some(
416
+ (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
417
+ );
418
+ if (!hasExport) {
419
+ if (logger) {
420
+ logger.warn(`Mastra ${option} config could not be extracted. Please make sure your entry file looks like this:
421
+ export const mastra = new Mastra({
422
+ ${option}: <value>
423
+ })
424
+
425
+ `);
426
+ }
427
+ const fallbackExportDeclaration = t.exportNamedDeclaration(
428
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
429
+ []
430
+ );
431
+ path3.node.body.push(fallbackExportDeclaration);
432
+ }
433
+ }
434
+ }
435
+ }
436
+ };
437
+ }
438
+
439
+ // src/build/plugins/remove-all-except.ts
440
+ function removeAllOptionsFromMastraExceptPlugin(mastraEntry, name, result, options) {
441
+ return {
442
+ name: `remove-${name}`,
443
+ transform(code, id) {
444
+ if (id !== mastraEntry) {
445
+ return;
446
+ }
447
+ return new Promise((resolve2, reject) => {
448
+ babel__namespace.transform(
449
+ code,
450
+ {
451
+ babelrc: false,
452
+ configFile: false,
453
+ filename: id,
454
+ plugins: [removeAllOptionsFromMastraExcept(result, name, options?.logger)],
455
+ sourceMaps: options?.sourcemap
456
+ },
457
+ (err, result2) => {
458
+ if (err) {
459
+ return reject(err);
460
+ }
461
+ resolve2({
462
+ code: result2.code,
463
+ map: result2.map
464
+ });
465
+ }
466
+ );
467
+ });
468
+ }
469
+ };
470
+ }
471
+
472
+ // src/build/shared/extract-mastra-option.ts
473
+ function extractMastraOptionBundler(name, entryFile, result, logger) {
445
474
  return rollup.rollup({
446
475
  logLevel: "silent",
447
476
  input: {
@@ -462,34 +491,7 @@ function extractMastraOptionBundler(name, entryFile, transformer, result, logger
462
491
  ignoreTryCatch: false
463
492
  }),
464
493
  json__default.default(),
465
- {
466
- name: `extract-${name}-config`,
467
- transform(code, id) {
468
- if (id !== entryFile) {
469
- return;
470
- }
471
- return new Promise((resolve2, reject) => {
472
- babel__namespace.transform(
473
- code,
474
- {
475
- babelrc: false,
476
- configFile: false,
477
- filename: id,
478
- plugins: [transformer(result, logger)]
479
- },
480
- (err, result2) => {
481
- if (err) {
482
- return reject(err);
483
- }
484
- resolve2({
485
- code: result2.code,
486
- map: result2.map
487
- });
488
- }
489
- );
490
- });
491
- }
492
- },
494
+ removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),
493
495
  // let esbuild remove all unused imports
494
496
  esbuild(),
495
497
  {
@@ -506,11 +508,11 @@ function extractMastraOptionBundler(name, entryFile, transformer, result, logger
506
508
  ]
507
509
  });
508
510
  }
509
- async function extractMastraOption(name, entryFile, transformer, outputDir, logger) {
511
+ async function extractMastraOption(name, entryFile, outputDir, logger) {
510
512
  const result = {
511
513
  hasCustomConfig: false
512
514
  };
513
- const bundler = await extractMastraOptionBundler(name, entryFile, transformer, result, logger);
515
+ const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);
514
516
  const output = await bundler.write({
515
517
  dir: outputDir,
516
518
  format: "es",
@@ -528,13 +530,7 @@ async function extractMastraOption(name, entryFile, transformer, outputDir, logg
528
530
 
529
531
  // src/build/bundlerOptions.ts
530
532
  async function getBundlerOptions(entryFile, outputDir, logger) {
531
- const result = await extractMastraOption(
532
- "bundler",
533
- entryFile,
534
- removeAllOptionsExceptBundler,
535
- outputDir,
536
- logger
537
- );
533
+ const result = await extractMastraOption("bundler", entryFile, outputDir, logger);
538
534
  if (!result) {
539
535
  return null;
540
536
  }
@@ -603,8 +599,57 @@ function isNodeBuiltin(dep) {
603
599
  const [pkg2] = dep.split("/");
604
600
  return dep.startsWith("node:") || module$1.builtinModules.includes(dep) || module$1.builtinModules.includes(pkg2);
605
601
  }
602
+ async function getPackageRootPath(packageName, parentPath) {
603
+ let rootPath;
604
+ try {
605
+ let options = void 0;
606
+ if (parentPath) {
607
+ if (!parentPath.startsWith("file://")) {
608
+ parentPath = url.pathToFileURL(parentPath).href;
609
+ }
610
+ options = {
611
+ paths: [parentPath]
612
+ };
613
+ }
614
+ const pkg2 = await localPkg.getPackageInfo(packageName, options);
615
+ rootPath = pkg2?.rootPath ?? null;
616
+ } catch (e) {
617
+ rootPath = null;
618
+ }
619
+ return rootPath;
620
+ }
621
+
622
+ // src/build/analyze/constants.ts
623
+ var DEPS_TO_IGNORE = ["#tools"];
624
+ var GLOBAL_EXTERNALS = [
625
+ "pino",
626
+ "pino-pretty",
627
+ "@libsql/client",
628
+ "pg",
629
+ "libsql",
630
+ "#tools",
631
+ "typescript",
632
+ "undici",
633
+ "readable-stream"
634
+ ];
635
+ var DEPRECATED_EXTERNALS = ["fastembed", "nodemailer", "jsdom", "sqlite3"];
606
636
  function removeDeployer() {
607
637
  const t = babel__namespace.default.types;
638
+ function removeDeployerFromObject(objectExpr, scope) {
639
+ const deployerProp = objectExpr.properties.find(
640
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
641
+ );
642
+ if (deployerProp) {
643
+ objectExpr.properties = objectExpr.properties.filter((prop) => prop !== deployerProp);
644
+ if (t.isIdentifier(deployerProp.value)) {
645
+ const deployerBinding = scope.getBinding(deployerProp.value.name);
646
+ if (deployerBinding) {
647
+ deployerBinding.path?.parentPath?.remove();
648
+ }
649
+ }
650
+ }
651
+ return deployerProp;
652
+ }
608
653
  return {
609
654
  name: "remove-deployer",
610
655
  visitor: {
@@ -620,23 +665,30 @@ function removeDeployer() {
620
665
  if (!state.hasReplaced) {
621
666
  state.hasReplaced = true;
622
667
  const newMastraObj = t.cloneNode(path3.node);
623
- if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {
624
- const deployer = newMastraObj.arguments[0].properties.find(
625
- (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
626
- );
627
- if (!deployer) {
628
- return;
668
+ if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.length) {
669
+ const objectArg = newMastraObj.arguments[0];
670
+ let foundDeployer = false;
671
+ const directDeployer = removeDeployerFromObject(objectArg, state.file.scope);
672
+ if (directDeployer) {
673
+ foundDeployer = true;
629
674
  }
630
- newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(
631
- (prop) => prop !== deployer
632
- );
633
- if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {
634
- const deployerBinding = state.file.scope.getBinding(deployer.value.name);
635
- if (deployerBinding) {
636
- deployerBinding?.path?.parentPath?.remove();
675
+ for (const prop of objectArg.properties) {
676
+ if (t.isSpreadElement(prop) && t.isIdentifier(prop.argument)) {
677
+ const spreadBinding = state.file.scope.getBinding(prop.argument.name);
678
+ if (spreadBinding?.path && t.isVariableDeclarator(spreadBinding.path.node)) {
679
+ const init = spreadBinding.path.node.init;
680
+ if (t.isObjectExpression(init)) {
681
+ const spreadDeployer = removeDeployerFromObject(init, state.file.scope);
682
+ if (spreadDeployer) {
683
+ foundDeployer = true;
684
+ }
685
+ }
686
+ }
637
687
  }
638
688
  }
639
- path3.replaceWith(newMastraObj);
689
+ if (foundDeployer) {
690
+ path3.replaceWith(newMastraObj);
691
+ }
640
692
  }
641
693
  }
642
694
  }
@@ -676,40 +728,6 @@ function removeDeployer2(mastraEntry, options) {
676
728
  }
677
729
  };
678
730
  }
679
- async function getPackageRootPath(packageName, parentPath) {
680
- let rootPath;
681
- try {
682
- let options = void 0;
683
- if (parentPath) {
684
- if (!parentPath.startsWith("file://")) {
685
- parentPath = url.pathToFileURL(parentPath).href;
686
- }
687
- options = {
688
- paths: [parentPath]
689
- };
690
- }
691
- const pkg2 = await localPkg.getPackageInfo(packageName, options);
692
- rootPath = pkg2?.rootPath ?? null;
693
- } catch (e) {
694
- rootPath = null;
695
- }
696
- return rootPath;
697
- }
698
-
699
- // src/build/analyze/constants.ts
700
- var DEPS_TO_IGNORE = ["#tools"];
701
- var GLOBAL_EXTERNALS = [
702
- "pino",
703
- "pino-pretty",
704
- "@libsql/client",
705
- "pg",
706
- "libsql",
707
- "#tools",
708
- "typescript",
709
- "undici",
710
- "readable-stream"
711
- ];
712
- var DEPRECATED_EXTERNALS = ["fastembed", "nodemailer", "jsdom", "sqlite3"];
713
731
 
714
732
  // src/build/analyze/analyzeEntry.ts
715
733
  function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }) {
@@ -750,7 +768,9 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
750
768
  transformMixedEsModules: true,
751
769
  extensions: [".js", ".ts"]
752
770
  }),
753
- removeDeployer2(mastraEntry, { sourcemap: sourcemapEnabled }),
771
+ removeDeployer2(mastraEntry, {
772
+ sourcemap: sourcemapEnabled
773
+ }),
754
774
  esbuild()
755
775
  ]
756
776
  );
@@ -1666,7 +1686,7 @@ async function analyzeBundle(entries, mastraEntry, {
1666
1686
  outputDir,
1667
1687
  projectRoot,
1668
1688
  isDev = false,
1669
- bundlerOptions: internalBundlerOptions
1689
+ bundlerOptions
1670
1690
  }, logger) {
1671
1691
  const mastraConfig = await promises.readFile(mastraEntry, "utf-8");
1672
1692
  const mastraConfigResult = {
@@ -1685,25 +1705,22 @@ export const mastra = new Mastra({
1685
1705
 
1686
1706
  If you think your configuration is valid, please open an issue.`);
1687
1707
  }
1688
- const { externals: _bundlerExternals = [] } = internalBundlerOptions || {};
1689
- const userBundlerOptions = await getBundlerOptions(mastraEntry, outputDir);
1690
1708
  const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: mastraEntry });
1691
1709
  let externalsPreset = false;
1692
- if (userBundlerOptions?.externals === true) {
1710
+ const userExternals = Array.isArray(bundlerOptions?.externals) ? bundlerOptions?.externals : [];
1711
+ if (bundlerOptions?.externals === true) {
1693
1712
  externalsPreset = true;
1694
1713
  }
1695
1714
  let index = 0;
1696
1715
  const depsToOptimize = /* @__PURE__ */ new Map();
1697
- const bundlerExternals = Array.isArray(_bundlerExternals) ? _bundlerExternals : [];
1698
- const userExternals = Array.isArray(userBundlerOptions?.externals) ? userBundlerOptions?.externals : [];
1699
- const allExternals = [...GLOBAL_EXTERNALS, ...bundlerExternals, ...userExternals];
1716
+ const allExternals = [...GLOBAL_EXTERNALS, ...userExternals].filter(Boolean);
1700
1717
  logger.info("Analyzing dependencies...");
1701
1718
  const allUsedExternals = /* @__PURE__ */ new Set();
1702
1719
  for (const entry of entries) {
1703
1720
  const isVirtualFile = entry.includes("\n") || !fs.existsSync(entry);
1704
1721
  const analyzeResult = await analyzeEntry({ entry, isVirtualFile }, mastraEntry, {
1705
1722
  logger,
1706
- sourcemapEnabled: userBundlerOptions?.sourcemap ?? false,
1723
+ sourcemapEnabled: bundlerOptions?.enableSourcemap ?? false,
1707
1724
  workspaceMap,
1708
1725
  projectRoot,
1709
1726
  shouldCheckTransitiveDependencies: isDev || externalsPreset
@@ -1738,8 +1755,8 @@ If you think your configuration is valid, please open an issue.`);
1738
1755
  logger.debug(`${sortedDeps.map((key) => `- ${key}`).join("\n")}`);
1739
1756
  const { output, fileNameToDependencyMap, usedExternals } = await bundleExternals(depsToOptimize, outputDir, {
1740
1757
  bundlerOptions: {
1741
- ...userBundlerOptions,
1742
- externals: userBundlerOptions?.externals ?? allExternals,
1758
+ ...bundlerOptions,
1759
+ externals: bundlerOptions?.externals ?? allExternals,
1743
1760
  isDev
1744
1761
  },
1745
1762
  projectRoot,
@@ -1794,9 +1811,8 @@ exports.extractMastraOption = extractMastraOption;
1794
1811
  exports.getBundlerOptions = getBundlerOptions;
1795
1812
  exports.getPackageRootPath = getPackageRootPath;
1796
1813
  exports.getWorkspaceInformation = getWorkspaceInformation;
1797
- exports.removeAllOptionsFromMastraExcept = removeAllOptionsFromMastraExcept;
1798
1814
  exports.removeDeployer = removeDeployer2;
1799
1815
  exports.subpathExternalsResolver = subpathExternalsResolver;
1800
1816
  exports.tsConfigPaths = tsConfigPaths;
1801
- //# sourceMappingURL=chunk-KCGBR2X6.cjs.map
1802
- //# sourceMappingURL=chunk-KCGBR2X6.cjs.map
1817
+ //# sourceMappingURL=chunk-CRIOGWZD.cjs.map
1818
+ //# sourceMappingURL=chunk-CRIOGWZD.cjs.map