@mastra/deployer 0.14.0-alpha.3 → 0.14.0-alpha.4

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 (87) hide show
  1. package/dist/build/analyze.cjs +3 -3
  2. package/dist/build/analyze.d.ts.map +1 -1
  3. package/dist/build/analyze.js +1 -1
  4. package/dist/build/babel/remove-all-options-bundler.d.ts +2 -1
  5. package/dist/build/babel/remove-all-options-bundler.d.ts.map +1 -1
  6. package/dist/build/babel/remove-all-options-deployer.d.ts +5 -0
  7. package/dist/build/babel/remove-all-options-deployer.d.ts.map +1 -0
  8. package/dist/build/babel/remove-all-options-except.d.ts +2 -1
  9. package/dist/build/babel/remove-all-options-except.d.ts.map +1 -1
  10. package/dist/build/babel/remove-all-options-server.d.ts +2 -1
  11. package/dist/build/babel/remove-all-options-server.d.ts.map +1 -1
  12. package/dist/build/babel/remove-all-options-telemetry.d.ts +1 -1
  13. package/dist/build/babel/remove-all-options-telemetry.d.ts.map +1 -1
  14. package/dist/build/bundler.cjs +3 -3
  15. package/dist/build/bundler.d.ts.map +1 -1
  16. package/dist/build/bundler.js +1 -1
  17. package/dist/build/bundlerOptions.d.ts +3 -2
  18. package/dist/build/bundlerOptions.d.ts.map +1 -1
  19. package/dist/build/customInstrumentation.d.ts.map +1 -1
  20. package/dist/build/deployer.d.ts +4 -3
  21. package/dist/build/deployer.d.ts.map +1 -1
  22. package/dist/build/index.cjs +12 -12
  23. package/dist/build/index.js +4 -4
  24. package/dist/build/plugins/esbuild.d.ts +3 -0
  25. package/dist/build/plugins/esbuild.d.ts.map +1 -0
  26. package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
  27. package/dist/build/serverOptions.d.ts +3 -2
  28. package/dist/build/serverOptions.d.ts.map +1 -1
  29. package/dist/build/shared/extract-mastra-option.d.ts +15 -0
  30. package/dist/build/shared/extract-mastra-option.d.ts.map +1 -0
  31. package/dist/build/telemetry.d.ts +3 -11
  32. package/dist/build/telemetry.d.ts.map +1 -1
  33. package/dist/bundler/index.cjs +2 -2
  34. package/dist/bundler/index.d.ts.map +1 -1
  35. package/dist/bundler/index.js +1 -1
  36. package/dist/{chunk-SA7YCRKF.js → chunk-3ZVEABRA.js} +21 -100
  37. package/dist/chunk-3ZVEABRA.js.map +1 -0
  38. package/dist/{chunk-3RRMEPHU.js → chunk-4HS72TCL.js} +13 -24
  39. package/dist/chunk-4HS72TCL.js.map +1 -0
  40. package/dist/{chunk-J42QUFVB.cjs → chunk-FIOHFXQ4.cjs} +8 -14
  41. package/dist/chunk-FIOHFXQ4.cjs.map +1 -0
  42. package/dist/{chunk-MRJUFOEN.cjs → chunk-G4TSJE4W.cjs} +47 -52
  43. package/dist/chunk-G4TSJE4W.cjs.map +1 -0
  44. package/dist/{chunk-4CTQZBDI.js → chunk-GXPWEOOA.js} +43 -47
  45. package/dist/chunk-GXPWEOOA.js.map +1 -0
  46. package/dist/chunk-HHNOUMJH.js +26 -0
  47. package/dist/chunk-HHNOUMJH.js.map +1 -0
  48. package/dist/{chunk-VAE7BL7I.cjs → chunk-LG5W6D2R.cjs} +19 -10
  49. package/dist/chunk-LG5W6D2R.cjs.map +1 -0
  50. package/dist/{chunk-OOVC5E4J.js → chunk-NOI4CTSN.js} +18 -10
  51. package/dist/chunk-NOI4CTSN.js.map +1 -0
  52. package/dist/{chunk-N66CXJKO.js → chunk-SBEJU32H.js} +4 -9
  53. package/dist/chunk-SBEJU32H.js.map +1 -0
  54. package/dist/chunk-UD4WRJI3.cjs +28 -0
  55. package/dist/chunk-UD4WRJI3.cjs.map +1 -0
  56. package/dist/{chunk-PBN66NLE.cjs → chunk-UYBVYWPG.cjs} +24 -124
  57. package/dist/chunk-UYBVYWPG.cjs.map +1 -0
  58. package/dist/{chunk-PO2BAZ5A.cjs → chunk-V7XDPQFQ.cjs} +19 -31
  59. package/dist/chunk-V7XDPQFQ.cjs.map +1 -0
  60. package/dist/index.cjs +20 -154
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.js +19 -129
  63. package/dist/index.js.map +1 -1
  64. package/dist/server/handlers/routes/agents/handlers.d.ts +12 -1
  65. package/dist/server/handlers/routes/agents/handlers.d.ts.map +1 -1
  66. package/dist/server/handlers/routes/agents/router.d.ts.map +1 -1
  67. package/dist/server/handlers/routes/scores/handlers.d.ts +50 -0
  68. package/dist/server/handlers/routes/scores/handlers.d.ts.map +1 -1
  69. package/dist/server/index.cjs +228 -5
  70. package/dist/server/index.cjs.map +1 -1
  71. package/dist/server/index.js +229 -6
  72. package/dist/server/index.js.map +1 -1
  73. package/package.json +5 -5
  74. package/dist/chunk-3RRMEPHU.js.map +0 -1
  75. package/dist/chunk-4CTQZBDI.js.map +0 -1
  76. package/dist/chunk-EFPKWUPY.js +0 -107
  77. package/dist/chunk-EFPKWUPY.js.map +0 -1
  78. package/dist/chunk-J42QUFVB.cjs.map +0 -1
  79. package/dist/chunk-MRJUFOEN.cjs.map +0 -1
  80. package/dist/chunk-N66CXJKO.js.map +0 -1
  81. package/dist/chunk-OOVC5E4J.js.map +0 -1
  82. package/dist/chunk-PBN66NLE.cjs.map +0 -1
  83. package/dist/chunk-PO2BAZ5A.cjs.map +0 -1
  84. package/dist/chunk-SA7YCRKF.js.map +0 -1
  85. package/dist/chunk-VAE7BL7I.cjs.map +0 -1
  86. package/dist/chunk-ZGXUX6Z6.cjs +0 -133
  87. package/dist/chunk-ZGXUX6Z6.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { tsConfigPaths, removeDeployer } from './chunk-OOVC5E4J.js';
1
+ import { esbuild, tsConfigPaths, removeDeployer } from './chunk-NOI4CTSN.js';
2
2
  import * as babel from '@babel/core';
3
3
  import babel__default from '@babel/core';
4
4
  import commonjs2 from '@rollup/plugin-commonjs';
@@ -8,10 +8,9 @@ import virtual from '@rollup/plugin-virtual';
8
8
  import { existsSync } from 'fs';
9
9
  import { writeFile, readFile } from 'fs/promises';
10
10
  import { fileURLToPath } from 'url';
11
- import { dirname, join } from 'path';
12
11
  import { rollup } from 'rollup';
13
- import esbuild from 'rollup-plugin-esbuild';
14
12
  import { builtinModules } from 'module';
13
+ import { dirname, join } from 'path';
15
14
  import { spawn as spawn$1 } from 'child_process';
16
15
  import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
17
16
  import resolveFrom from 'resolve-from';
@@ -148,8 +147,8 @@ export const mastra = new Mastra({
148
147
  }
149
148
 
150
149
  // src/build/babel/remove-all-options-bundler.ts
151
- function removeAllOptionsExceptBundler(result) {
152
- return removeAllOptionsFromMastraExcept(result, "bundler");
150
+ function removeAllOptionsExceptBundler(result, logger) {
151
+ return removeAllOptionsFromMastraExcept(result, "bundler", logger);
153
152
  }
154
153
  function removeNonReferencedNodes() {
155
154
  const t = babel__default.types;
@@ -224,21 +223,17 @@ function recursiveRemoveNonReferencedNodes(code) {
224
223
  );
225
224
  });
226
225
  }
227
- function getBundlerOptionsBundler(entryFile, result) {
226
+ function extractMastraOptionBundler(name, entryFile, transformer, result, logger) {
228
227
  return rollup({
229
228
  logLevel: "silent",
230
229
  input: {
231
- "bundler-config": entryFile
230
+ [`${name}-config`]: entryFile
232
231
  },
233
232
  treeshake: "smallest",
234
233
  plugins: [
235
234
  tsConfigPaths(),
236
235
  // transpile typescript to something we understand
237
- esbuild({
238
- target: "node20",
239
- platform: "node",
240
- minify: false
241
- }),
236
+ esbuild(),
242
237
  optimizeLodashImports(),
243
238
  commonjs2({
244
239
  extensions: [".js", ".ts"],
@@ -248,7 +243,7 @@ function getBundlerOptionsBundler(entryFile, result) {
248
243
  }),
249
244
  json2(),
250
245
  {
251
- name: "get-bundler-config",
246
+ name: `extract-${name}-config`,
252
247
  transform(code, id) {
253
248
  if (id !== entryFile) {
254
249
  return;
@@ -260,7 +255,7 @@ function getBundlerOptionsBundler(entryFile, result) {
260
255
  babelrc: false,
261
256
  configFile: false,
262
257
  filename: id,
263
- plugins: [removeAllOptionsExceptBundler(result)]
258
+ plugins: [transformer(result, logger)]
264
259
  },
265
260
  (err, result2) => {
266
261
  if (err) {
@@ -276,11 +271,7 @@ function getBundlerOptionsBundler(entryFile, result) {
276
271
  }
277
272
  },
278
273
  // let esbuild remove all unused imports
279
- esbuild({
280
- target: "node20",
281
- platform: "node",
282
- minify: false
283
- }),
274
+ esbuild(),
284
275
  {
285
276
  name: "cleanup",
286
277
  transform(code, id) {
@@ -290,30 +281,45 @@ function getBundlerOptionsBundler(entryFile, result) {
290
281
  return recursiveRemoveNonReferencedNodes(code);
291
282
  }
292
283
  },
293
- // let esbuild remove all unused imports
294
- esbuild({
295
- target: "node20",
296
- platform: "node",
297
- minify: false
298
- })
284
+ // let esbuild remove it once more
285
+ esbuild()
299
286
  ]
300
287
  });
301
288
  }
302
- async function getBundlerOptions(entryFile, outputDir) {
289
+ async function extractMastraOption(name, entryFile, transformer, outputDir, logger) {
303
290
  const result = {
304
291
  hasCustomConfig: false
305
292
  };
306
- const bundle = await getBundlerOptionsBundler(entryFile, result);
307
- await bundle.write({
293
+ const bundler = await extractMastraOptionBundler(name, entryFile, transformer, result, logger);
294
+ const output = await bundler.write({
308
295
  dir: outputDir,
309
296
  format: "es",
310
297
  entryFileNames: "[name].mjs"
311
298
  });
312
299
  if (result.hasCustomConfig) {
313
- return (await import(`file:${outputDir}/bundler-config.mjs`)).bundler;
300
+ const configPath = `${outputDir}/${name}-config.mjs`;
301
+ return {
302
+ bundleOutput: output,
303
+ getConfig: () => import(`file:${configPath}`).then((m) => m[name])
304
+ };
314
305
  }
315
306
  return null;
316
307
  }
308
+
309
+ // src/build/bundlerOptions.ts
310
+ async function getBundlerOptions(entryFile, outputDir, logger) {
311
+ const result = await extractMastraOption(
312
+ "bundler",
313
+ entryFile,
314
+ removeAllOptionsExceptBundler,
315
+ outputDir,
316
+ logger
317
+ );
318
+ if (!result) {
319
+ return null;
320
+ }
321
+ return result.getConfig();
322
+ }
317
323
  function checkConfigExport(result) {
318
324
  const t = babel__default.types;
319
325
  const mastraVars = /* @__PURE__ */ new Set();
@@ -424,11 +430,7 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger, sour
424
430
  }
425
431
  },
426
432
  json2(),
427
- esbuild({
428
- target: "node20",
429
- platform,
430
- minify: false
431
- }),
433
+ esbuild(),
432
434
  commonjs2({
433
435
  strictRequires: "debug",
434
436
  ignoreTryCatch: false,
@@ -436,11 +438,7 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger, sour
436
438
  extensions: [".js", ".ts"]
437
439
  }),
438
440
  removeDeployer(normalizedMastraEntry, { sourcemap: sourcemapEnabled }),
439
- esbuild({
440
- target: "node20",
441
- platform,
442
- minify: false
443
- })
441
+ esbuild()
444
442
  ].filter(Boolean)
445
443
  });
446
444
  const { output } = await optimizerBundler.generate({
@@ -536,11 +534,12 @@ async function bundleExternals(depsToOptimize, outputDir, logger, options) {
536
534
  ),
537
535
  options?.isDev ? {
538
536
  name: "external-resolver",
539
- resolveId(id, importer) {
537
+ async resolveId(id, importer, options2) {
540
538
  const pathsToTranspile = [...transpilePackagesMap.values()];
541
539
  if (importer && pathsToTranspile.some((p) => importer?.startsWith(p)) && !isRelativePath(id)) {
540
+ const resolved = await this.resolve(id, importer, { skipSelf: true, ...options2 });
542
541
  return {
543
- id: resolveFrom(importer, id),
542
+ ...resolved,
544
543
  external: true
545
544
  };
546
545
  }
@@ -548,10 +547,7 @@ async function bundleExternals(depsToOptimize, outputDir, logger, options) {
548
547
  }
549
548
  } : null,
550
549
  transpilePackagesMap.size ? esbuild({
551
- target: "node20",
552
- platform: "node",
553
550
  format: "esm",
554
- minify: false,
555
551
  include: [...transpilePackagesMap.values()].map((p) => {
556
552
  return new RegExp(`^${p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/(?!.*node_modules).*$`);
557
553
  })
@@ -681,6 +677,6 @@ If you think your configuration is valid, please open an issue.`);
681
677
  return result;
682
678
  }
683
679
 
684
- export { aliasHono, analyzeBundle, bundleExternals, getBundlerOptions, recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept };
685
- //# sourceMappingURL=chunk-4CTQZBDI.js.map
686
- //# sourceMappingURL=chunk-4CTQZBDI.js.map
680
+ export { aliasHono, analyzeBundle, bundleExternals, extractMastraOption, getBundlerOptions, removeAllOptionsFromMastraExcept };
681
+ //# sourceMappingURL=chunk-GXPWEOOA.js.map
682
+ //# sourceMappingURL=chunk-GXPWEOOA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/isNodeBuiltin.ts","../src/build/plugins/hono-alias.ts","../src/validator/validate.ts","../src/build/babel/remove-all-options-except.ts","../src/build/babel/remove-all-options-bundler.ts","../src/build/babel/remove-non-referenced-nodes.ts","../src/build/plugins/remove-unused-references.ts","../src/build/shared/extract-mastra-option.ts","../src/build/bundlerOptions.ts","../src/build/babel/check-config-export.ts","../src/build/analyze.ts"],"names":["nodeSpawn","babel","path","babel3","commonjs","json","babel4","result","rollup","fileURLToPath","dirname","options","o","babel6"],"mappings":";;;;;;;;;;;;;;;;;;AAEO,SAAS,cAAc,GAAA,EAAsB;AAClD,EAAA,MAAM,CAAC,GAAG,CAAA,GAAI,GAAA,CAAI,MAAM,GAAG,CAAA;AAE3B,EAAA,OAAO,GAAA,CAAI,UAAA,CAAW,OAAO,CAAA,IAAK,cAAA,CAAe,SAAS,GAAG,CAAA,IAAK,cAAA,CAAe,QAAA,CAAS,GAAI,CAAA;AAChG;ACFO,SAAS,SAAA,GAAoB;AAClC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,YAAA;AAAA,IACN,UAAU,EAAA,EAAY;AACpB,MAAA,IAAI,CAAC,EAAA,CAAG,UAAA,CAAW,QAAQ,CAAA,IAAK,CAAC,EAAA,CAAG,UAAA,CAAW,OAAO,CAAA,IAAK,EAAA,KAAO,MAAA,IAAU,OAAO,cAAA,EAAgB;AACjG,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,IAAA,GAAO,MAAA,CAAA,IAAA,CAAY,OAAA,CAAQ,EAAE,CAAA;AACnC,MAAA,OAAO,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AA,EAAU,EAAG,MAAM,CAAA;AAE5G,EAAA,OAAO,MAAA;AACT","file":"chunk-GXPWEOOA.js","sourcesContent":["import { builtinModules } from 'node:module';\n\nexport function isNodeBuiltin(dep: string): boolean {\n const [pkg] = dep.split('/');\n\n return dep.startsWith('node:') || builtinModules.includes(dep) || builtinModules.includes(pkg!);\n}\n","import { fileURLToPath } from 'node:url';\nimport type { Plugin } from 'rollup';\n\n// hono is imported from deployer, so we need to resolve from here instead of the project root\nexport function aliasHono(): Plugin {\n return {\n name: 'hono-alias',\n resolveId(id: string) {\n if (!id.startsWith('@hono/') && !id.startsWith('hono/') && id !== 'hono' && id !== 'hono-openapi') {\n return;\n }\n\n const path = import.meta.resolve(id);\n return fileURLToPath(path);\n },\n } satisfies Plugin;\n}\n","import { spawn as nodeSpawn } from 'node:child_process';\nimport type { SpawnOptions } from 'node:child_process';\nimport { dirname } from 'node:path';\n\n/**\n * Promisified version of Node.js spawn function\n *\n * @param command - The command to run\n * @param args - List of string arguments\n * @param options - Spawn options\n * @returns Promise that resolves with the exit code when the process completes\n */\nfunction spawn(command: string, args: string[] = [], options: SpawnOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const childProcess = nodeSpawn(command, args, {\n // stdio: 'inherit',\n ...options,\n });\n\n childProcess.on('error', error => {\n reject(error);\n });\n\n let stderr = '';\n childProcess.stderr?.on('data', message => {\n stderr += message;\n });\n\n childProcess.on('close', code => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(stderr));\n }\n });\n });\n}\n\nexport function validate(file: string) {\n return spawn(\n 'node',\n [\n '--import',\n import.meta.resolve('@mastra/deployer/loader'),\n '--input-type=module',\n '-e',\n `import('file://${file.replaceAll('\\\\', '/')}')`,\n ],\n {\n cwd: dirname(file),\n },\n );\n}\n","import babel from '@babel/core';\nimport type { NodePath, types } from '@babel/core';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function removeAllOptionsFromMastraExcept(\n result: { hasCustomConfig: boolean },\n option: keyof MastraConfig,\n logger?: IMastraLogger,\n) {\n const t = babel.types;\n\n return {\n name: 'remove-all-except-' + option + '-config',\n visitor: {\n ExportNamedDeclaration: {\n // remove all exports\n exit(path) {\n path.remove();\n },\n },\n\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n let mastraArgs = t.objectExpression([]);\n if (t.isObjectExpression(path.node.arguments[0])) {\n mastraArgs = path.node.arguments[0];\n }\n\n let telemetry = mastraArgs.properties.find(\n // @ts-ignore\n prop => prop.key.name === option,\n );\n let telemetryValue: types.Expression = t.objectExpression([]);\n\n const programPath = path.scope.getProgramParent().path as NodePath<types.Program> | undefined;\n if (!programPath) {\n return;\n }\n\n if (telemetry && t.isObjectProperty(telemetry) && t.isExpression(telemetry.value)) {\n result.hasCustomConfig = true;\n telemetryValue = telemetry.value;\n\n if (t.isIdentifier(telemetry.value) && telemetry.value.name === option) {\n const telemetryBinding = state.file.scope.getBinding(option)!;\n\n if (telemetryBinding && t.isVariableDeclarator(telemetryBinding.path.node)) {\n const id = path.scope.generateUidIdentifier(option);\n\n telemetryBinding.path.replaceWith(t.variableDeclarator(id, telemetryBinding.path.node.init!));\n telemetryValue = id;\n }\n }\n }\n\n // add the deployer export\n const exportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), telemetryValue)]),\n [],\n );\n\n programPath.node.body.push(exportDeclaration);\n },\n\n Program: {\n exit(path) {\n // Add a fallback export if no mastra configuration was found\n const hasExport = path.node.body.some(\n node => node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration',\n );\n\n if (!hasExport) {\n if (logger) {\n logger.warn(`Mastra ${option} config could not be extracted. Please make sure your entry file looks like this:\nexport const mastra = new Mastra({\n ${option}: <value>\n})\n\n`);\n }\n\n const fallbackExportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),\n [],\n );\n path.node.body.push(fallbackExportDeclaration);\n }\n },\n },\n },\n } as babel.PluginObj;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport { removeAllOptionsFromMastraExcept } from './remove-all-options-except';\n\nexport function removeAllOptionsExceptBundler(result: { hasCustomConfig: boolean }, logger?: IMastraLogger) {\n return removeAllOptionsFromMastraExcept(result, 'bundler', logger);\n}\n","import babel from '@babel/core';\n\nexport function removeNonReferencedNodes() {\n const t = babel.types;\n\n return {\n name: 'remove-non-referenced-nodes',\n visitor: {\n Program(path) {\n // Get the scope information\n const scope = path.scope;\n\n // Filter body to keep only referenced nodes\n const currentBody = path.get('body');\n const filteredBody = currentBody.filter(childPath => {\n if (childPath.isExportDeclaration()) {\n return true;\n }\n\n // For variable declarations, check if any declared variables are referenced\n if (childPath.isVariableDeclaration()) {\n return childPath.node.declarations.some(decl => {\n if (!t.isIdentifier(decl.id)) {\n return false;\n }\n\n const name = decl.id.name;\n const binding = scope.getBinding(name);\n // Keep if it has references or is exported\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // For function/class declarations, check if they're referenced\n if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {\n if (!t.isIdentifier(childPath.node.id)) {\n return false;\n }\n\n const name = childPath.node.id.name;\n const binding = scope.getBinding(name);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n }\n\n // For imports, check if any imported items are referenced\n if (childPath.isImportDeclaration()) {\n return childPath.node.specifiers.some(specifier => {\n const importedName = specifier.local.name;\n const binding = scope.getBinding(importedName);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // Default to keeping other node types\n return false;\n });\n\n // Replace the program body with filtered nodes\n path.set(\n 'body',\n filteredBody.map(p => p.node),\n );\n },\n },\n } as babel.PluginObj;\n}\n","import * as babel from '@babel/core';\nimport { removeNonReferencedNodes } from '../babel/remove-non-referenced-nodes';\n\nexport function recursiveRemoveNonReferencedNodes(code: string) {\n return new Promise<{ code: string; map: any }>(async (resolve, reject) => {\n babel.transform(\n code,\n {\n babelrc: false,\n configFile: false,\n plugins: [removeNonReferencedNodes()],\n },\n (err, result) => {\n if (err) {\n return reject(err);\n }\n\n // keep looping until the code is not changed\n if (result && result.code! !== code) {\n return recursiveRemoveNonReferencedNodes(result!.code!).then(resolve, reject);\n }\n\n resolve({\n code: result!.code!,\n map: result!.map!,\n });\n },\n );\n });\n}\n","import * as babel from '@babel/core';\nimport { rollup, type RollupOutput } from 'rollup';\nimport { esbuild } from '../plugins/esbuild';\nimport commonjs from '@rollup/plugin-commonjs';\nimport { tsConfigPaths } from '../plugins/tsconfig-paths';\nimport { recursiveRemoveNonReferencedNodes } from '../plugins/remove-unused-references';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport { removeAllOptionsFromMastraExcept } from '../babel/remove-all-options-except';\nimport json from '@rollup/plugin-json';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\ntype Transformer = (\n result: { hasCustomConfig: boolean },\n logger?: IMastraLogger,\n) => ReturnType<typeof removeAllOptionsFromMastraExcept>;\n\nexport function extractMastraOptionBundler(\n name: string,\n entryFile: string,\n transformer: Transformer,\n result: {\n hasCustomConfig: false;\n },\n logger?: IMastraLogger,\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n [`${name}-config`]: entryFile,\n },\n treeshake: 'smallest',\n plugins: [\n tsConfigPaths(),\n // transpile typescript to something we understand\n esbuild(),\n optimizeLodashImports(),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n json(),\n {\n name: `extract-${name}-config`,\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n babel.transform(\n code,\n {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [transformer(result, logger)],\n },\n (err, result) => {\n if (err) {\n return reject(err);\n }\n\n resolve({\n code: result!.code!,\n map: result!.map!,\n });\n },\n );\n });\n },\n },\n // let esbuild remove all unused imports\n esbuild(),\n {\n name: 'cleanup',\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return recursiveRemoveNonReferencedNodes(code);\n },\n },\n // let esbuild remove it once more\n esbuild(),\n ],\n });\n}\n\nexport async function extractMastraOption<T>(\n name: string,\n entryFile: string,\n transformer: Transformer,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{\n bundleOutput: RollupOutput;\n getConfig: () => Promise<T>;\n} | null> {\n const result = {\n hasCustomConfig: false,\n } as const;\n const bundler = await extractMastraOptionBundler(name, entryFile, transformer, result, logger);\n\n const output = await bundler.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n });\n\n if (result.hasCustomConfig) {\n const configPath = `${outputDir}/${name}-config.mjs`;\n\n return {\n bundleOutput: output,\n getConfig: () => import(`file:${configPath}`).then(m => m[name] as T),\n };\n }\n\n return null;\n}\n","import { removeAllOptionsExceptBundler } from './babel/remove-all-options-bundler';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function getBundlerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('bundler', entryFile, removeAllOptionsExceptBundler, result);\n}\n\nexport async function getBundlerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['bundler'] | null> {\n const result = await extractMastraOption<Config['bundler']>(\n 'bundler',\n entryFile,\n removeAllOptionsExceptBundler,\n outputDir,\n logger,\n );\n\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n","import type { PluginObj } from '@babel/core';\nimport babel from '@babel/core';\n\nexport function checkConfigExport(result: { hasValidConfig: boolean }): PluginObj {\n const t = babel.types;\n // Track which local variable names are assigned to `new Mastra()`\n const mastraVars = new Set<string>();\n\n return {\n visitor: {\n ExportNamedDeclaration(path) {\n const decl = path.node.declaration;\n // 1) export const mastra = new Mastra(...)\n if (t.isVariableDeclaration(decl)) {\n const varDecl = decl.declarations[0];\n if (\n t.isIdentifier(varDecl?.id, { name: 'mastra' }) &&\n t.isNewExpression(varDecl.init) &&\n t.isIdentifier(varDecl.init.callee, { name: 'Mastra' })\n ) {\n result.hasValidConfig = true;\n }\n }\n /**\n * 2) export { foo as mastra }\n * 3) export { mastra }\n * 4) export { mastra, foo }\n */\n if (Array.isArray(path.node.specifiers)) {\n for (const spec of path.node.specifiers) {\n if (\n t.isExportSpecifier(spec) &&\n t.isIdentifier(spec.exported, { name: 'mastra' }) &&\n t.isIdentifier(spec.local) &&\n mastraVars.has(spec.local.name)\n ) {\n result.hasValidConfig = true;\n }\n }\n }\n },\n // For cases 2-4 we need to track whether those variables are assigned to `new Mastra()`\n VariableDeclaration(path) {\n for (const decl of path.node.declarations) {\n if (\n t.isIdentifier(decl.id) &&\n t.isNewExpression(decl.init) &&\n t.isIdentifier(decl.init.callee, { name: 'Mastra' })\n ) {\n mastraVars.add(decl.id.name);\n }\n }\n },\n },\n };\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport * as babel from '@babel/core';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport virtual from '@rollup/plugin-virtual';\nimport { existsSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { fileURLToPath } from 'node:url';\nimport { rollup, type OutputAsset, type OutputChunk, type Plugin } from 'rollup';\nimport { esbuild } from './plugins/esbuild';\nimport { isNodeBuiltin } from './isNodeBuiltin';\nimport { aliasHono } from './plugins/hono-alias';\nimport { removeDeployer } from './plugins/remove-deployer';\nimport { dirname, join } from 'node:path';\nimport { validate } from '../validator/validate';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport { writeFile } from 'node:fs/promises';\nimport { getBundlerOptions } from './bundlerOptions';\nimport resolveFrom from 'resolve-from';\nimport { packageDirectory } from 'package-directory';\nimport { checkConfigExport } from './babel/check-config-export';\n\n// TODO: Make thie extendable or find a rollup plugin that can do this\nconst globalExternals = [\n 'pino',\n 'pino-pretty',\n '@libsql/client',\n 'pg',\n 'libsql',\n 'jsdom',\n 'sqlite3',\n 'fastembed',\n 'nodemailer',\n '#tools',\n];\n\nfunction findExternalImporter(module: OutputChunk, external: string, allOutputs: OutputChunk[]): OutputChunk | null {\n const capturedFiles = new Set();\n\n for (const id of module.imports) {\n if (id === external) {\n return module;\n } else {\n if (id.endsWith('.mjs')) {\n capturedFiles.add(id);\n }\n }\n }\n\n for (const file of capturedFiles) {\n const nextModule = allOutputs.find(o => o.fileName === file);\n if (nextModule) {\n const importer = findExternalImporter(nextModule, external, allOutputs);\n\n if (importer) {\n return importer;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Check if a path is relative without relying on `isAbsolute()` as we want to allow package names (e.g. `@pkg/name`)\n */\nfunction isRelativePath(id: string): boolean {\n return id === '.' || id === '..' || id.startsWith('./') || id.startsWith('../');\n}\n\n/**\n * Analyzes the entry file to identify dependencies that need optimization.\n * This is the first step of the bundle analysis process.\n *\n * @param entry - The entry file path or content\n * @param mastraEntry - The mastra entry point\n * @param isVirtualFile - Whether the entry is a virtual file (content string) or a file path\n * @param platform - Target platform (node or browser)\n * @param logger - Logger instance for debugging\n * @returns Map of dependencies to optimize with their exported bindings\n */\nasync function analyze(\n entry: string,\n mastraEntry: string,\n isVirtualFile: boolean,\n platform: 'node' | 'browser',\n logger: IMastraLogger,\n sourcemapEnabled: boolean = false,\n) {\n logger.info('Analyzing dependencies...');\n let virtualPlugin = null;\n if (isVirtualFile) {\n virtualPlugin = virtual({\n '#entry': entry,\n });\n entry = '#entry';\n }\n\n const normalizedMastraEntry = mastraEntry.replaceAll('\\\\', '/');\n const optimizerBundler = await rollup({\n logLevel: process.env.MASTRA_BUNDLER_DEBUG === 'true' ? 'debug' : 'silent',\n input: isVirtualFile ? '#entry' : entry,\n treeshake: 'smallest',\n preserveSymlinks: true,\n plugins: [\n virtualPlugin,\n tsConfigPaths(),\n {\n name: 'custom-alias-resolver',\n resolveId(id: string) {\n if (id === '#server') {\n return fileURLToPath(import.meta.resolve('@mastra/deployer/server')).replaceAll('\\\\', '/');\n }\n if (id === '#mastra') {\n return normalizedMastraEntry;\n }\n if (id.startsWith('@mastra/server')) {\n return fileURLToPath(import.meta.resolve(id));\n }\n\n // Tools is generated dependency, we don't want it to be handled by the bundler but instead read from disk at runtime\n if (id === '#tools') {\n return {\n id: '#tools',\n external: true,\n };\n }\n },\n } satisfies Plugin,\n json(),\n esbuild(),\n commonjs({\n strictRequires: 'debug',\n ignoreTryCatch: false,\n transformMixedEsModules: true,\n extensions: ['.js', '.ts'],\n }),\n removeDeployer(normalizedMastraEntry, { sourcemap: sourcemapEnabled }),\n esbuild(),\n ].filter(Boolean),\n });\n\n const { output } = await optimizerBundler.generate({\n format: 'esm',\n inlineDynamicImports: true,\n });\n\n await optimizerBundler.close();\n\n const depsToOptimize = new Map(Object.entries(output[0].importedBindings));\n for (const dep of depsToOptimize.keys()) {\n if (isNodeBuiltin(dep)) {\n depsToOptimize.delete(dep);\n }\n }\n\n for (const o of output) {\n if (o.type !== 'chunk') {\n continue;\n }\n\n // Tools is generated dependency, we don't want our analyzer to handle it\n const dynamicImports = o.dynamicImports.filter(d => d !== '#tools');\n if (!dynamicImports.length) {\n continue;\n }\n\n for (const dynamicImport of dynamicImports) {\n if (!depsToOptimize.has(dynamicImport) && !isNodeBuiltin(dynamicImport)) {\n depsToOptimize.set(dynamicImport, ['*']);\n }\n }\n }\n\n return depsToOptimize;\n}\n\n/**\n * Bundles vendor dependencies identified in the analysis step.\n * Creates virtual modules for each dependency and bundles them using rollup.\n *\n * @param depsToOptimize - Map of dependencies with their exports from analyze step\n * @param outputDir - Directory where bundled files will be written\n * @param logger - Logger instance for debugging\n * @returns Object containing bundle output and reference map for validation\n */\nexport async function bundleExternals(\n depsToOptimize: Map<string, string[]>,\n outputDir: string,\n logger: IMastraLogger,\n options?: {\n externals?: string[];\n transpilePackages?: string[];\n isDev?: boolean;\n },\n) {\n logger.info('Optimizing dependencies...');\n logger.debug(\n `${Array.from(depsToOptimize.keys())\n .map(key => `- ${key}`)\n .join('\\n')}`,\n );\n\n const { externals: customExternals = [], transpilePackages = [] } = options || {};\n const allExternals = [...globalExternals, ...customExternals];\n const reverseVirtualReferenceMap = new Map<string, string>();\n const virtualDependencies = new Map();\n for (const [dep, exports] of depsToOptimize.entries()) {\n const name = dep.replaceAll('/', '-');\n reverseVirtualReferenceMap.set(name, dep);\n\n const virtualFile: string[] = [];\n let exportStringBuilder = [];\n for (const local of exports) {\n if (local === '*') {\n virtualFile.push(`export * from '${dep}';`);\n } else if (local === 'default') {\n virtualFile.push(`export { default } from '${dep}';`);\n } else {\n exportStringBuilder.push(local);\n }\n }\n\n if (exportStringBuilder.length > 0) {\n virtualFile.push(`export { ${exportStringBuilder.join(', ')} } from '${dep}';`);\n }\n\n virtualDependencies.set(dep, {\n name,\n virtual: virtualFile.join('\\n'),\n });\n }\n\n const transpilePackagesMap = new Map<string, string>();\n for (const pkg of transpilePackages) {\n const entryPoint = dirname(resolveFrom(outputDir, pkg));\n const dir = await packageDirectory({\n cwd: entryPoint,\n });\n if (dir) {\n transpilePackagesMap.set(pkg, dir);\n }\n }\n\n const bundler = await rollup({\n logLevel: process.env.MASTRA_BUNDLER_DEBUG === 'true' ? 'debug' : 'silent',\n input: Array.from(virtualDependencies.entries()).reduce(\n (acc, [dep, virtualDep]) => {\n acc[virtualDep.name] = `#virtual-${dep}`;\n return acc;\n },\n {} as Record<string, string>,\n ),\n // this dependency breaks the build, so we need to exclude it\n // TODO actually fix this so we don't need to exclude it\n external: allExternals,\n treeshake: 'smallest',\n plugins: [\n virtual(\n Array.from(virtualDependencies.entries()).reduce(\n (acc, [dep, virtualDep]) => {\n acc[`#virtual-${dep}`] = virtualDep.virtual;\n return acc;\n },\n {} as Record<string, string>,\n ),\n ),\n options?.isDev\n ? ({\n name: 'external-resolver',\n async resolveId(id, importer, options) {\n const pathsToTranspile = [...transpilePackagesMap.values()];\n if (importer && pathsToTranspile.some(p => importer?.startsWith(p)) && !isRelativePath(id)) {\n const resolved = await this.resolve(id, importer, { skipSelf: true, ...options });\n\n return {\n ...resolved,\n external: true,\n };\n }\n\n return null;\n },\n } as Plugin)\n : null,\n transpilePackagesMap.size\n ? esbuild({\n format: 'esm',\n include: [...transpilePackagesMap.values()].map(p => {\n // Match files from transpilePackages but exclude any nested node_modules\n // Escapes regex special characters in the path and uses negative lookahead to avoid node_modules\n // generated by cursor\n return new RegExp(`^${p.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}/(?!.*node_modules).*$`);\n }),\n })\n : null,\n commonjs({\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n nodeResolve({\n preferBuiltins: true,\n exportConditions: ['node'],\n }),\n // hono is imported from deployer, so we need to resolve from here instead of the project root\n aliasHono(),\n json(),\n ].filter(Boolean),\n });\n\n const { output } = await bundler.write({\n format: 'esm',\n dir: outputDir,\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n hoistTransitiveImports: false,\n });\n const moduleResolveMap = {} as Record<string, Record<string, string>>;\n const filteredChunks = output.filter(o => o.type === 'chunk');\n\n for (const o of filteredChunks.filter(o => o.isEntry || o.isDynamicEntry)) {\n for (const external of allExternals) {\n if (external === '#tools') {\n continue;\n }\n\n const importer = findExternalImporter(o, external, filteredChunks);\n\n if (importer) {\n const fullPath = join(outputDir, importer.fileName);\n moduleResolveMap[fullPath] = moduleResolveMap[fullPath] || {};\n if (importer.moduleIds.length) {\n moduleResolveMap[fullPath][external] = importer.moduleIds[importer.moduleIds.length - 1]?.startsWith(\n '\\x00virtual:#virtual',\n )\n ? importer.moduleIds[importer.moduleIds.length - 2]!\n : importer.moduleIds[importer.moduleIds.length - 1]!;\n }\n }\n }\n }\n\n await writeFile(join(outputDir, 'module-resolve-map.json'), JSON.stringify(moduleResolveMap, null, 2));\n\n await bundler.close();\n\n return { output, reverseVirtualReferenceMap, usedExternals: moduleResolveMap };\n}\n\n/**\n * Validates the bundled output by attempting to import each generated module.\n * Tracks invalid chunks and external dependencies that couldn't be bundled.\n *\n * @param output - Bundle output from rollup\n * @param reverseVirtualReferenceMap - Map to resolve virtual module names back to original deps\n * @param outputDir - Directory containing the bundled files\n * @param logger - Logger instance for debugging\n * @returns Analysis result containing invalid chunks and dependency mappings\n */\nasync function validateOutput(\n {\n output,\n reverseVirtualReferenceMap,\n usedExternals,\n outputDir,\n }: {\n output: (OutputChunk | OutputAsset)[];\n reverseVirtualReferenceMap: Map<string, string>;\n usedExternals: Record<string, Record<string, string>>;\n outputDir: string;\n },\n logger: IMastraLogger,\n) {\n const result = {\n invalidChunks: new Set<string>(),\n dependencies: new Map<string, string>(),\n externalDependencies: new Set<string>(),\n };\n\n // we should resolve the version of the deps\n for (const deps of Object.values(usedExternals)) {\n for (const dep of Object.keys(deps)) {\n result.externalDependencies.add(dep);\n }\n }\n\n for (const file of output) {\n if (file.type === 'asset') {\n continue;\n }\n\n try {\n logger.debug(`Validating if ${file.fileName} is a valid module.`);\n if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {\n result.dependencies.set(reverseVirtualReferenceMap.get(file.name)!, file.fileName);\n }\n\n if (!file.isDynamicEntry && file.isEntry) {\n // validate if the chunk is actually valid, a failsafe to make sure bundling didn't make any mistakes\n await validate(join(outputDir, file.fileName));\n }\n } catch (err) {\n result.invalidChunks.add(file.fileName);\n if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {\n const reference = reverseVirtualReferenceMap.get(file.name)!;\n const dep = reference.startsWith('@') ? reference.split('/').slice(0, 2).join('/') : reference.split('/')[0];\n\n result.externalDependencies.add(dep!);\n }\n\n // we might need this on other projects but not sure so let's keep it commented out for now\n // console.log(file.fileName, file.isEntry, file.isDynamicEntry, err);\n // result.invalidChunks.add(file.fileName);\n // const externalImports = excludeInternalDeps(file.imports.filter(file => !internalFiles.has(file)));\n // externalImports.push(...excludeInternalDeps(file.dynamicImports.filter(file => !internalFiles.has(file))));\n // for (const externalImport of externalImports) {\n // result.externalDependencies.add(externalImport);\n // }\n\n // if (reverseVirtualReferenceMap.has(file.name)) {\n // result.externalDependencies.add(reverseVirtualReferenceMap.get(file.name)!);\n // }\n }\n }\n\n return result;\n}\n\n/**\n * Main bundle analysis function that orchestrates the three-step process:\n * 1. Analyze dependencies\n * 2. Bundle dependencies modules\n * 3. Validate generated bundles\n *\n * This helps identify which dependencies need to be externalized vs bundled.\n */\nexport async function analyzeBundle(\n entries: string[],\n mastraEntry: string,\n outputDir: string,\n platform: 'node' | 'browser',\n logger: IMastraLogger,\n sourcemapEnabled: boolean = false,\n) {\n const mastraConfig = await readFile(mastraEntry, 'utf-8');\n const mastraConfigResult = {\n hasValidConfig: false,\n } as const;\n\n await babel.transformAsync(mastraConfig, {\n filename: mastraEntry,\n presets: [import.meta.resolve('@babel/preset-typescript')],\n plugins: [checkConfigExport(mastraConfigResult)],\n });\n\n if (!mastraConfigResult.hasValidConfig) {\n logger.warn(`Invalid Mastra config. Please make sure that your entry file looks like this:\nexport const mastra = new Mastra({\n // your options\n})\n \nIf you think your configuration is valid, please open an issue.`);\n }\n\n const depsToOptimize = new Map<string, string[]>();\n for (const entry of entries) {\n const isVirtualFile = entry.includes('\\n') || !existsSync(entry);\n const analyzeResult = await analyze(entry, mastraEntry, isVirtualFile, platform, logger, sourcemapEnabled);\n\n for (const [dep, exports] of analyzeResult.entries()) {\n if (depsToOptimize.has(dep)) {\n // Merge with existing exports if dependency already exists\n const existingExports = depsToOptimize.get(dep)!;\n depsToOptimize.set(dep, [...new Set([...existingExports, ...exports])]);\n } else {\n depsToOptimize.set(dep, exports);\n }\n }\n }\n const bundlerOptions = await getBundlerOptions(mastraEntry, outputDir);\n\n const { output, reverseVirtualReferenceMap, usedExternals } = await bundleExternals(\n depsToOptimize,\n outputDir,\n logger,\n bundlerOptions ?? undefined,\n );\n const result = await validateOutput({ output, reverseVirtualReferenceMap, usedExternals, outputDir }, logger);\n\n return result;\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import { extractMastraOption, removeAllOptionsFromMastraExcept } from './chunk-GXPWEOOA.js';
2
+
3
+ // src/build/babel/remove-all-options-telemetry.ts
4
+ function removeAllOptionsExceptTelemetry(result, logger) {
5
+ return removeAllOptionsFromMastraExcept(result, "telemetry", logger);
6
+ }
7
+
8
+ // src/build/telemetry.ts
9
+ async function writeTelemetryConfig(entryFile, outputDir, logger) {
10
+ const result = await extractMastraOption(
11
+ "telemetry",
12
+ entryFile,
13
+ removeAllOptionsExceptTelemetry,
14
+ outputDir,
15
+ logger
16
+ );
17
+ if (!result) {
18
+ return null;
19
+ }
20
+ const externals = result.bundleOutput.output[0].imports.filter((x) => !x.startsWith("./"));
21
+ return { externalDependencies: externals };
22
+ }
23
+
24
+ export { writeTelemetryConfig };
25
+ //# sourceMappingURL=chunk-HHNOUMJH.js.map
26
+ //# sourceMappingURL=chunk-HHNOUMJH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/babel/remove-all-options-telemetry.ts","../src/build/telemetry.ts"],"names":[],"mappings":";;;AAGO,SAAS,+BAAA,CAAgC,QAAsC,MAAA,EAAwB;AAC5G,EAAA,OAAO,gCAAA,CAAiC,MAAA,EAAQ,WAAA,EAAa,MAAM,CAAA;AACrE;;;ACSA,eAAsB,oBAAA,CACpB,SAAA,EACA,SAAA,EACA,MAAA,EACoD;AACpD,EAAA,MAAM,SAAS,MAAM,mBAAA;AAAA,IACnB,WAAA;AAAA,IACA,SAAA;AAAA,IACA,+BAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,YAAA,CAAa,MAAA,CAAO,CAAC,CAAA,CAAE,OAAA,CAAQ,MAAA,CAAO,CAAA,CAAA,KAAK,CAAC,CAAA,CAAE,UAAA,CAAW,IAAI,CAAC,CAAA;AAEvF,EAAA,OAAO,EAAE,sBAAsB,SAAA,EAAU;AAC3C","file":"chunk-HHNOUMJH.js","sourcesContent":["import { removeAllOptionsFromMastraExcept } from './remove-all-options-except';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function removeAllOptionsExceptTelemetry(result: { hasCustomConfig: boolean }, logger?: IMastraLogger) {\n return removeAllOptionsFromMastraExcept(result, 'telemetry', logger);\n}\n","import { removeAllOptionsExceptTelemetry } from './babel/remove-all-options-telemetry';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function getTelemetryBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('telemetry', entryFile, removeAllOptionsExceptTelemetry, result);\n}\n\nexport async function writeTelemetryConfig(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{ externalDependencies: string[] } | null> {\n const result = await extractMastraOption<Config['telemetry']>(\n 'telemetry',\n entryFile,\n removeAllOptionsExceptTelemetry,\n outputDir,\n logger,\n );\n\n if (!result) {\n return null;\n }\n\n const externals = result.bundleOutput.output[0].imports.filter(x => !x.startsWith('./'));\n\n return { externalDependencies: externals };\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var originalEsbuild = require('rollup-plugin-esbuild');
3
4
  var babel = require('@babel/core');
4
5
  var fs = require('fs');
5
6
  var path = require('path');
6
- var resolveFrom = require('resolve-from');
7
7
  var typescriptPaths = require('typescript-paths');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -26,12 +26,20 @@ function _interopNamespace(e) {
26
26
  return Object.freeze(n);
27
27
  }
28
28
 
29
+ var originalEsbuild__default = /*#__PURE__*/_interopDefault(originalEsbuild);
29
30
  var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
30
31
  var fs__default = /*#__PURE__*/_interopDefault(fs);
31
32
  var path__default = /*#__PURE__*/_interopDefault(path);
32
- var resolveFrom__default = /*#__PURE__*/_interopDefault(resolveFrom);
33
33
 
34
- // src/build/plugins/remove-deployer.ts
34
+ // src/build/plugins/esbuild.ts
35
+ function esbuild(options = {}) {
36
+ return originalEsbuild__default.default({
37
+ target: "node20",
38
+ platform: "node",
39
+ minify: false,
40
+ ...options
41
+ });
42
+ }
35
43
  function removeDeployer() {
36
44
  const t = babel__namespace.default.types;
37
45
  return {
@@ -127,20 +135,20 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
127
135
  const moduleName = handler?.(request, path.normalize(importer));
128
136
  if (!moduleName) {
129
137
  let importerMeta = {};
138
+ const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });
139
+ if (!resolved) {
140
+ return null;
141
+ }
130
142
  if (localResolve) {
131
143
  const importerInfo = this.getModuleInfo(importer);
132
144
  importerMeta = importerInfo?.meta || {};
133
145
  if (!request.startsWith("./") && !request.startsWith("../") && importerMeta?.[PLUGIN_NAME]?.resolved) {
134
146
  return {
135
- id: resolveFrom__default.default(importer, request) ?? null,
147
+ ...resolved,
136
148
  external: true
137
149
  };
138
150
  }
139
151
  }
140
- const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });
141
- if (!resolved) {
142
- return null;
143
- }
144
152
  return {
145
153
  ...resolved,
146
154
  meta: {
@@ -176,7 +184,8 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
176
184
  };
177
185
  }
178
186
 
187
+ exports.esbuild = esbuild;
179
188
  exports.removeDeployer = removeDeployer2;
180
189
  exports.tsConfigPaths = tsConfigPaths;
181
- //# sourceMappingURL=chunk-VAE7BL7I.cjs.map
182
- //# sourceMappingURL=chunk-VAE7BL7I.cjs.map
190
+ //# sourceMappingURL=chunk-LG5W6D2R.cjs.map
191
+ //# sourceMappingURL=chunk-LG5W6D2R.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/plugins/esbuild.ts","../src/build/babel/remove-deployer.ts","../src/build/plugins/remove-deployer.ts","../src/build/plugins/tsconfig-paths.ts"],"names":["originalEsbuild","babel","path","removeDeployer","babel2","createHandler","fs","normalize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAAS,OAAA,CAAQ,OAAA,GAAiD,EAAC,EAAG;AAC3E,EAAA,OAAOA,gCAAA,CAAgB;AAAA,IACrB,MAAA,EAAQ,QAAA;AAAA,IACR,QAAA,EAAU,MAAA;AAAA,IACV,MAAA,EAAQ,KAAA;AAAA,IACR,GAAG;AAAA,GACJ,CAAA;AACH;ACPO,SAAS,cAAA,GAAiB;AAC/B,EAAA,MAAM,IAAIC,wBAAA,CAAM,KAAA;AAEhB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,iBAAA;AAAA,IACN,OAAA,EAAS;AAAA,MACP,aAAA,CAAcC,OAAM,KAAA,EAAO;AAEzB,QAAA,MAAM,iBAAA,GAAoBA,MAAK,UAAA,CAAW,CAAAA,UAAQ,CAAA,CAAE,oBAAA,CAAqBA,KAAAA,CAAK,IAAI,CAAC,CAAA;AACnF,QAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,UAAA;AAAA,QACF;AAEA,QAAA,MAAM,UAAA,GAAaA,MAAK,UAAA,CAAW,IAAA;AAEnC,QAAA,IAAI,CAAC,CAAA,CAAE,oBAAA,CAAqB,UAAU,KAAK,CAAC,CAAA,CAAE,YAAA,CAAa,UAAA,CAAW,EAAE,CAAA,IAAK,UAAA,CAAW,EAAA,CAAG,SAAS,QAAA,EAAU;AAC5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,CAAQ,UAAA,EAAY,QAAA,EAAU,EAAE,QAAA,EAAU,IAAA,EAAM,GAAG,OAAA,EAAS,CAAA;AAExF,QAAA,IAAI,CAAC,QAAA,EAAU;AACb,UAAA,OAAO,IAAA;AAAA,QACT;AAEA,QAAA,OAAO;AAAA,UACL,GAAG,QAAA;AAAA,UACH,IAAA,EAAM;AAAA,YACJ,GAAG,QAAA,CAAS,IAAA;AAAA,YACZ,CAAC,WAAW,GAAG;AAAA,cACb,QAAA,EAAU;AAAA;AACZ;AACF,SACF;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,EAAA,EAAI,UAAA;AAAA,QACJ,IAAA,EAAM;AAAA,UACJ,CAAC,WAAW,GAAG;AAAA,YACb,QAAA,EAAU;AAAA;AACZ;AACF,OACF;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-LG5W6D2R.cjs","sourcesContent":["import originalEsbuild from 'rollup-plugin-esbuild';\n\nexport function esbuild(options: Parameters<typeof originalEsbuild>[0] = {}) {\n return originalEsbuild({\n target: 'node20',\n platform: 'node',\n minify: false,\n ...options,\n });\n}\n","import babel from '@babel/core';\n\nexport function removeDeployer() {\n const t = babel.types;\n\n return {\n name: 'remove-deployer',\n visitor: {\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n if (!state.hasReplaced) {\n state.hasReplaced = true;\n const newMastraObj = t.cloneNode(path.node);\n if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {\n const deployer = newMastraObj.arguments[0].properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === 'deployer',\n );\n\n if (!deployer) {\n return;\n }\n\n newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(\n prop => prop !== deployer,\n );\n\n // try to find the binding of the deployer which should be the reference to the deployer\n if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {\n const deployerBinding = state.file.scope.getBinding(deployer.value.name);\n\n if (deployerBinding) {\n deployerBinding?.path?.parentPath?.remove();\n }\n }\n\n path.replaceWith(newMastraObj);\n }\n }\n },\n },\n } as babel.PluginObj;\n}\n","import * as babel from '@babel/core';\nimport type { Plugin } from 'rollup';\n\nimport { removeDeployer as removeDeployerBabelPlugin } from '../babel/remove-deployer';\n\nexport function removeDeployer(mastraEntry: string, options?: { sourcemap?: boolean }): Plugin {\n return {\n name: 'remove-deployer',\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n babel.transform(\n code,\n {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [removeDeployerBabelPlugin],\n sourceMaps: options?.sourcemap,\n },\n (err, result) => {\n if (err) {\n return reject(err);\n }\n\n resolve({\n code: result!.code!,\n map: result!.map!,\n });\n },\n );\n });\n },\n } satisfies Plugin;\n}\n","import fs from 'node:fs';\nimport path, { normalize } from 'node:path';\nimport resolveFrom from 'resolve-from';\nimport type { Plugin } from 'rollup';\nimport type { RegisterOptions } from 'typescript-paths';\nimport { createHandler } from 'typescript-paths';\n\nconst PLUGIN_NAME = 'tsconfig-paths';\n\nexport type PluginOptions = Omit<RegisterOptions, 'loggerID'> & { localResolve?: boolean };\n\nexport function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve }: PluginOptions = {}): Plugin {\n let handler: ReturnType<typeof createHandler>;\n return {\n name: PLUGIN_NAME,\n buildStart() {\n handler = createHandler({\n log: () => {},\n tsConfigPath,\n respectCoreModule,\n falllback: moduleName => fs.existsSync(moduleName),\n });\n return;\n },\n async resolveId(request, importer, options) {\n if (!importer || request.startsWith('\\0')) {\n return null;\n }\n\n const moduleName = handler?.(request, normalize(importer));\n // No tsconfig alias found, so we need to resolve it normally\n if (!moduleName) {\n let importerMeta: { [PLUGIN_NAME]?: { resolved?: boolean } } = {};\n\n const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });\n if (!resolved) {\n return null;\n }\n\n // If localResolve is true, we need to check if the importer has been resolved by the tsconfig-paths plugin\n // if so, we need to resolve the request from the importer instead of the root and mark it as external\n if (localResolve) {\n const importerInfo = this.getModuleInfo(importer);\n importerMeta = importerInfo?.meta || {};\n\n if (!request.startsWith('./') && !request.startsWith('../') && importerMeta?.[PLUGIN_NAME]?.resolved) {\n return {\n ...resolved,\n external: true,\n };\n }\n }\n\n return {\n ...resolved,\n meta: {\n ...(resolved.meta || {}),\n ...importerMeta,\n },\n };\n }\n\n // When a module does not have an extension, we need to resolve it to a file\n if (!path.extname(moduleName)) {\n const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });\n\n if (!resolved) {\n return null;\n }\n\n return {\n ...resolved,\n meta: {\n ...resolved.meta,\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n }\n\n return {\n id: moduleName,\n meta: {\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n },\n } satisfies Plugin;\n}\n"]}
@@ -1,11 +1,19 @@
1
+ import originalEsbuild from 'rollup-plugin-esbuild';
1
2
  import * as babel from '@babel/core';
2
3
  import babel__default from '@babel/core';
3
4
  import fs from 'fs';
4
5
  import path, { normalize } from 'path';
5
- import resolveFrom from 'resolve-from';
6
6
  import { createHandler } from 'typescript-paths';
7
7
 
8
- // src/build/plugins/remove-deployer.ts
8
+ // src/build/plugins/esbuild.ts
9
+ function esbuild(options = {}) {
10
+ return originalEsbuild({
11
+ target: "node20",
12
+ platform: "node",
13
+ minify: false,
14
+ ...options
15
+ });
16
+ }
9
17
  function removeDeployer() {
10
18
  const t = babel__default.types;
11
19
  return {
@@ -101,20 +109,20 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
101
109
  const moduleName = handler?.(request, normalize(importer));
102
110
  if (!moduleName) {
103
111
  let importerMeta = {};
112
+ const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });
113
+ if (!resolved) {
114
+ return null;
115
+ }
104
116
  if (localResolve) {
105
117
  const importerInfo = this.getModuleInfo(importer);
106
118
  importerMeta = importerInfo?.meta || {};
107
119
  if (!request.startsWith("./") && !request.startsWith("../") && importerMeta?.[PLUGIN_NAME]?.resolved) {
108
120
  return {
109
- id: resolveFrom(importer, request) ?? null,
121
+ ...resolved,
110
122
  external: true
111
123
  };
112
124
  }
113
125
  }
114
- const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });
115
- if (!resolved) {
116
- return null;
117
- }
118
126
  return {
119
127
  ...resolved,
120
128
  meta: {
@@ -150,6 +158,6 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
150
158
  };
151
159
  }
152
160
 
153
- export { removeDeployer2 as removeDeployer, tsConfigPaths };
154
- //# sourceMappingURL=chunk-OOVC5E4J.js.map
155
- //# sourceMappingURL=chunk-OOVC5E4J.js.map
161
+ export { esbuild, removeDeployer2 as removeDeployer, tsConfigPaths };
162
+ //# sourceMappingURL=chunk-NOI4CTSN.js.map
163
+ //# sourceMappingURL=chunk-NOI4CTSN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/plugins/esbuild.ts","../src/build/babel/remove-deployer.ts","../src/build/plugins/remove-deployer.ts","../src/build/plugins/tsconfig-paths.ts"],"names":["babel","path","removeDeployer","babel2"],"mappings":";;;;;;;;AAEO,SAAS,OAAA,CAAQ,OAAA,GAAiD,EAAC,EAAG;AAC3E,EAAA,OAAO,eAAA,CAAgB;AAAA,IACrB,MAAA,EAAQ,QAAA;AAAA,IACR,QAAA,EAAU,MAAA;AAAA,IACV,MAAA,EAAQ,KAAA;AAAA,IACR,GAAG;AAAA,GACJ,CAAA;AACH;ACPO,SAAS,cAAA,GAAiB;AAC/B,EAAA,MAAM,IAAIA,cAAA,CAAM,KAAA;AAEhB,EAAA,OAAO;AAAA,IAC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,UAAA,CAAW,IAAI,CAAA,IAAK,CAAC,OAAA,CAAQ,UAAA,CAAW,KAAK,CAAA,IAAK,YAAA,GAAe,WAAW,GAAG,QAAA,EAAU;AACpG,YAAA,OAAO;AAAA,cACL,GAAG,QAAA;AAAA,cACH,QAAA,EAAU;AAAA,aACZ;AAAA,UACF;AAAA,QACF;AAEA,QAAA,OAAO;AAAA,UACL,GAAG,QAAA;AAAA,UACH,IAAA,EAAM;AAAA,YACJ,GAAI,QAAA,CAAS,IAAA,IAAQ,EAAC;AAAA,YACtB,GAAG;AAAA;AACL,SACF;AAAA,MACF;AAGA,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,UAAU,CAAA,EAAG;AAC7B,QAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,QAAA,EAAU,EAAE,QAAA,EAAU,IAAA,EAAM,GAAG,OAAA,EAAS,CAAA;AAExF,QAAA,IAAI,CAAC,QAAA,EAAU;AACb,UAAA,OAAO,IAAA;AAAA,QACT;AAEA,QAAA,OAAO;AAAA,UACL,GAAG,QAAA;AAAA,UACH,IAAA,EAAM;AAAA,YACJ,GAAG,QAAA,CAAS,IAAA;AAAA,YACZ,CAAC,WAAW,GAAG;AAAA,cACb,QAAA,EAAU;AAAA;AACZ;AACF,SACF;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,EAAA,EAAI,UAAA;AAAA,QACJ,IAAA,EAAM;AAAA,UACJ,CAAC,WAAW,GAAG;AAAA,YACb,QAAA,EAAU;AAAA;AACZ;AACF,OACF;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-NOI4CTSN.js","sourcesContent":["import originalEsbuild from 'rollup-plugin-esbuild';\n\nexport function esbuild(options: Parameters<typeof originalEsbuild>[0] = {}) {\n return originalEsbuild({\n target: 'node20',\n platform: 'node',\n minify: false,\n ...options,\n });\n}\n","import babel from '@babel/core';\n\nexport function removeDeployer() {\n const t = babel.types;\n\n return {\n name: 'remove-deployer',\n visitor: {\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n if (!state.hasReplaced) {\n state.hasReplaced = true;\n const newMastraObj = t.cloneNode(path.node);\n if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {\n const deployer = newMastraObj.arguments[0].properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === 'deployer',\n );\n\n if (!deployer) {\n return;\n }\n\n newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(\n prop => prop !== deployer,\n );\n\n // try to find the binding of the deployer which should be the reference to the deployer\n if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {\n const deployerBinding = state.file.scope.getBinding(deployer.value.name);\n\n if (deployerBinding) {\n deployerBinding?.path?.parentPath?.remove();\n }\n }\n\n path.replaceWith(newMastraObj);\n }\n }\n },\n },\n } as babel.PluginObj;\n}\n","import * as babel from '@babel/core';\nimport type { Plugin } from 'rollup';\n\nimport { removeDeployer as removeDeployerBabelPlugin } from '../babel/remove-deployer';\n\nexport function removeDeployer(mastraEntry: string, options?: { sourcemap?: boolean }): Plugin {\n return {\n name: 'remove-deployer',\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n babel.transform(\n code,\n {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [removeDeployerBabelPlugin],\n sourceMaps: options?.sourcemap,\n },\n (err, result) => {\n if (err) {\n return reject(err);\n }\n\n resolve({\n code: result!.code!,\n map: result!.map!,\n });\n },\n );\n });\n },\n } satisfies Plugin;\n}\n","import fs from 'node:fs';\nimport path, { normalize } from 'node:path';\nimport resolveFrom from 'resolve-from';\nimport type { Plugin } from 'rollup';\nimport type { RegisterOptions } from 'typescript-paths';\nimport { createHandler } from 'typescript-paths';\n\nconst PLUGIN_NAME = 'tsconfig-paths';\n\nexport type PluginOptions = Omit<RegisterOptions, 'loggerID'> & { localResolve?: boolean };\n\nexport function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve }: PluginOptions = {}): Plugin {\n let handler: ReturnType<typeof createHandler>;\n return {\n name: PLUGIN_NAME,\n buildStart() {\n handler = createHandler({\n log: () => {},\n tsConfigPath,\n respectCoreModule,\n falllback: moduleName => fs.existsSync(moduleName),\n });\n return;\n },\n async resolveId(request, importer, options) {\n if (!importer || request.startsWith('\\0')) {\n return null;\n }\n\n const moduleName = handler?.(request, normalize(importer));\n // No tsconfig alias found, so we need to resolve it normally\n if (!moduleName) {\n let importerMeta: { [PLUGIN_NAME]?: { resolved?: boolean } } = {};\n\n const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });\n if (!resolved) {\n return null;\n }\n\n // If localResolve is true, we need to check if the importer has been resolved by the tsconfig-paths plugin\n // if so, we need to resolve the request from the importer instead of the root and mark it as external\n if (localResolve) {\n const importerInfo = this.getModuleInfo(importer);\n importerMeta = importerInfo?.meta || {};\n\n if (!request.startsWith('./') && !request.startsWith('../') && importerMeta?.[PLUGIN_NAME]?.resolved) {\n return {\n ...resolved,\n external: true,\n };\n }\n }\n\n return {\n ...resolved,\n meta: {\n ...(resolved.meta || {}),\n ...importerMeta,\n },\n };\n }\n\n // When a module does not have an extension, we need to resolve it to a file\n if (!path.extname(moduleName)) {\n const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });\n\n if (!resolved) {\n return null;\n }\n\n return {\n ...resolved,\n meta: {\n ...resolved.meta,\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n }\n\n return {\n id: moduleName,\n meta: {\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n },\n } satisfies Plugin;\n}\n"]}
@@ -1,11 +1,10 @@
1
- import { tsConfigPaths, removeDeployer } from './chunk-OOVC5E4J.js';
1
+ import { tsConfigPaths, esbuild, removeDeployer } from './chunk-NOI4CTSN.js';
2
2
  import alias from '@rollup/plugin-alias';
3
3
  import commonjs from '@rollup/plugin-commonjs';
4
4
  import json from '@rollup/plugin-json';
5
5
  import nodeResolve from '@rollup/plugin-node-resolve';
6
6
  import { fileURLToPath } from 'url';
7
7
  import { rollup } from 'rollup';
8
- import esbuild from 'rollup-plugin-esbuild';
9
8
  import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
10
9
 
11
10
  async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = { "process.env.NODE_ENV": JSON.stringify("production") }, { sourcemap = false } = {}) {
@@ -88,9 +87,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
88
87
  }
89
88
  },
90
89
  esbuild({
91
- target: "node20",
92
90
  platform,
93
- minify: false,
94
91
  define: env
95
92
  }),
96
93
  optimizeLodashImports(),
@@ -121,9 +118,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
121
118
  // treeshake unused imports
122
119
  esbuild({
123
120
  include: entryFile,
124
- target: "node20",
125
- platform,
126
- minify: false
121
+ platform
127
122
  })
128
123
  ].filter(Boolean)
129
124
  };
@@ -146,5 +141,5 @@ async function createBundler(inputOptions, outputOptions) {
146
141
  }
147
142
 
148
143
  export { createBundler, getInputOptions };
149
- //# sourceMappingURL=chunk-N66CXJKO.js.map
150
- //# sourceMappingURL=chunk-N66CXJKO.js.map
144
+ //# sourceMappingURL=chunk-SBEJU32H.js.map
145
+ //# sourceMappingURL=chunk-SBEJU32H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/build/bundler.ts"],"names":[],"mappings":";;;;;;;;;AAYA,eAAsB,gBACpB,SAAA,EACA,kBAAA,EACA,QAAA,EACA,GAAA,GAA8B,EAAE,sBAAA,EAAwB,IAAA,CAAK,SAAA,CAAU,YAAY,GAAE,EACrF,EAAE,YAAY,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OAAO,MAAM;AACX,MAAA,OAAO,QAAQ,KAAA,EAAM;AAAA,IACvB;AAAA,GACF;AACF","file":"chunk-SBEJU32H.js","sourcesContent":["import alias from '@rollup/plugin-alias';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport { fileURLToPath } from 'node:url';\nimport { rollup, type InputOptions, type OutputOptions } from 'rollup';\nimport { esbuild } from './plugins/esbuild';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport type { analyzeBundle } from './analyze';\nimport { removeDeployer } from './plugins/remove-deployer';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\n\nexport async function getInputOptions(\n entryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n platform: 'node' | 'browser',\n env: Record<string, string> = { 'process.env.NODE_ENV': JSON.stringify('production') },\n { sourcemap = false }: { sourcemap?: boolean } = {},\n): Promise<InputOptions> {\n let nodeResolvePlugin =\n platform === 'node'\n ? nodeResolve({\n preferBuiltins: true,\n exportConditions: ['node'],\n })\n : nodeResolve({\n preferBuiltins: false,\n browser: true,\n });\n\n const externalsCopy = new Set<string>();\n // make all nested imports external from the same package\n for (const external of analyzedBundleInfo.externalDependencies) {\n if (external.startsWith('@')) {\n const [scope, name] = external.split('/', 3);\n externalsCopy.add(`${scope}/${name}`);\n externalsCopy.add(`${scope}/${name}/*`);\n } else {\n externalsCopy.add(external);\n externalsCopy.add(`${external}/*`);\n }\n }\n\n const externals = Array.from(externalsCopy);\n\n const normalizedEntryFile = entryFile.replaceAll('\\\\', '/');\n return {\n logLevel: process.env.MASTRA_BUNDLER_DEBUG === 'true' ? 'debug' : 'silent',\n treeshake: 'smallest',\n preserveSymlinks: true,\n external: externals,\n plugins: [\n {\n name: 'alias-optimized-deps',\n // @ts-ignore\n resolveId(id) {\n if (!analyzedBundleInfo.dependencies.has(id)) {\n return null;\n }\n\n const isInvalidChunk = analyzedBundleInfo.invalidChunks.has(analyzedBundleInfo.dependencies.get(id)!);\n if (isInvalidChunk) {\n return {\n id,\n external: true,\n };\n }\n\n return {\n id: '.mastra/.build/' + analyzedBundleInfo.dependencies.get(id)!,\n external: false,\n };\n },\n },\n tsConfigPaths(),\n alias({\n entries: [\n {\n find: /^\\#server$/,\n replacement: fileURLToPath(import.meta.resolve('@mastra/deployer/server')).replaceAll('\\\\', '/'),\n },\n {\n find: /^\\@mastra\\/server\\/(.*)/,\n replacement: `@mastra/server/$1`,\n customResolver: id => {\n if (id.startsWith('@mastra/server')) {\n return {\n id: fileURLToPath(import.meta.resolve(id)),\n };\n }\n },\n },\n { find: /^\\#mastra$/, replacement: normalizedEntryFile },\n ],\n }),\n {\n name: 'tools-rewriter',\n resolveId(id: string) {\n if (id === '#tools') {\n return {\n id: './tools.mjs',\n external: true,\n };\n }\n },\n },\n esbuild({\n platform,\n define: env,\n }),\n optimizeLodashImports(),\n commonjs({\n extensions: ['.js', '.ts'],\n transformMixedEsModules: true,\n esmExternals(id) {\n return externals.includes(id);\n },\n }),\n nodeResolvePlugin,\n // for debugging\n // {\n // name: 'logger',\n // //@ts-ignore\n // resolveId(id, ...args) {\n // console.log({ id, args });\n // },\n // // @ts-ignore\n // transform(code, id) {\n // if (code.includes('class Duplexify ')) {\n // console.log({ duplex: id });\n // }\n // },\n // },\n json(),\n removeDeployer(entryFile, { sourcemap }),\n // treeshake unused imports\n esbuild({\n include: entryFile,\n platform,\n }),\n ].filter(Boolean),\n } satisfies InputOptions;\n}\n\nexport async function createBundler(\n inputOptions: InputOptions,\n outputOptions: Partial<OutputOptions> & { dir: string },\n) {\n const bundler = await rollup(inputOptions);\n\n return {\n write: () => {\n return bundler.write({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n });\n },\n close: () => {\n return bundler.close();\n },\n };\n}\n"]}