@mastra/deployer 0.2.1-alpha.1 → 0.2.1

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 (37) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +60 -18
  2. package/dist/_tsup-dts-rollup.d.ts +60 -18
  3. package/dist/build/analyze.cjs +2 -2
  4. package/dist/build/analyze.js +1 -1
  5. package/dist/build/bundler.cjs +3 -3
  6. package/dist/build/bundler.js +1 -1
  7. package/dist/build/index.cjs +14 -14
  8. package/dist/build/index.js +4 -4
  9. package/dist/bundler/index.cjs +2 -2
  10. package/dist/bundler/index.js +1 -1
  11. package/dist/chunk-3H66SAKS.cjs +139 -0
  12. package/dist/{chunk-SL5KZNFT.js → chunk-7XQJJPRM.js} +26 -13
  13. package/dist/{chunk-72GFPLLU.js → chunk-DZ4D3KXZ.js} +4 -6
  14. package/dist/{chunk-YLIG5BNH.cjs → chunk-GLTC4BEQ.cjs} +42 -78
  15. package/dist/{chunk-J2F3DJTF.cjs → chunk-HLGZCQQW.cjs} +40 -22
  16. package/dist/{chunk-VPY2RQUP.js → chunk-HRR4D2GM.js} +29 -11
  17. package/dist/{chunk-TQSSPVHI.js → chunk-JNF4CXZJ.js} +42 -78
  18. package/dist/{chunk-PT5XTSU2.js → chunk-JNNKML56.js} +13 -1
  19. package/dist/{chunk-4LYFNYJ4.cjs → chunk-JSFQUYK4.cjs} +13 -1
  20. package/dist/{chunk-YJMYF7RI.cjs → chunk-PMHXFDK2.cjs} +8 -10
  21. package/dist/{chunk-VPP5727D.cjs → chunk-PRZC7CEM.cjs} +27 -14
  22. package/dist/chunk-XO6KJHXC.js +128 -0
  23. package/dist/index.cjs +16 -12
  24. package/dist/index.js +11 -7
  25. package/dist/server/index.cjs +183 -40
  26. package/dist/server/index.js +183 -40
  27. package/dist/validator/custom-resolver.cjs +33 -0
  28. package/dist/validator/custom-resolver.d.cts +1 -0
  29. package/dist/validator/custom-resolver.d.ts +1 -0
  30. package/dist/validator/custom-resolver.js +31 -0
  31. package/dist/validator/loader.cjs +7 -0
  32. package/dist/validator/loader.d.cts +1 -0
  33. package/dist/validator/loader.d.ts +1 -0
  34. package/dist/validator/loader.js +4 -0
  35. package/package.json +14 -3
  36. package/dist/chunk-AC67BJSW.js +0 -260
  37. package/dist/chunk-QFYK5AS3.cjs +0 -292
@@ -1,4 +1,4 @@
1
- import { removeDeployer } from './chunk-PT5XTSU2.js';
1
+ import { removeDeployer } from './chunk-JNNKML56.js';
2
2
  import commonjs from '@rollup/plugin-commonjs';
3
3
  import json from '@rollup/plugin-json';
4
4
  import nodeResolve from '@rollup/plugin-node-resolve';
@@ -8,6 +8,8 @@ import { fileURLToPath } from 'node:url';
8
8
  import { rollup } from 'rollup';
9
9
  import esbuild from 'rollup-plugin-esbuild';
10
10
  import { builtinModules } from 'node:module';
11
+ import { join } from 'node:path';
12
+ import { spawn as spawn$1 } from 'node:child_process';
11
13
 
12
14
  function isNodeBuiltin(dep) {
13
15
  const [pkg] = dep.split("/");
@@ -25,81 +27,40 @@ function aliasHono() {
25
27
  }
26
28
  };
27
29
  }
28
-
29
- // src/build/plugins/pino.ts
30
- function pino() {
31
- const workerFiles = [
32
- {
33
- id: "thread-stream-worker",
34
- file: "pino-thread-stream-worker"
35
- },
36
- {
37
- id: "pino-worker",
38
- file: "pino-worker"
39
- },
40
- {
41
- id: "pino/file",
42
- file: "pino-file"
43
- },
44
- {
45
- id: "pino-pretty",
46
- file: "pino-pretty"
47
- }
48
- ];
49
- const fileReferences = /* @__PURE__ */ new Map();
50
- return {
51
- name: "rollup-plugin-pino",
52
- async resolveId(id, importee) {
53
- if (id === "pino") {
54
- const resolvedPino = await this.resolve(id, importee);
55
- if (resolvedPino) {
56
- await Promise.all(
57
- workerFiles.map(async (file) => {
58
- const resolvedEntry = await this.resolve(file.id, resolvedPino.id);
59
- if (!resolvedEntry) {
60
- return null;
61
- }
62
- const reference = this.emitFile({
63
- type: "chunk",
64
- id: resolvedEntry.id,
65
- name: `${file.file}`
66
- });
67
- fileReferences.set(file.id, reference);
68
- })
69
- );
70
- }
71
- }
72
- },
73
- renderChunk(code, chunk) {
74
- if (chunk.type === "chunk" && chunk.isEntry && fileReferences.size && chunk.name === "index") {
75
- const importRegex = /^(?:import(?:["'\s]*[\w*${}\n\r\t, ]+from\s*)?["'\s].+[;"'\s]*)$/gm;
76
- const codeToInject = `globalThis.__bundlerPathsOverrides = {
77
- ${Array.from(fileReferences.entries()).map(([key, file]) => {
78
- return '"' + key + '": import.meta.ROLLUP_FILE_URL_' + file;
79
- }).join(",\n")}
80
- };`;
81
- const matches = Array.from(code.matchAll(importRegex));
82
- if (matches.length > 0) {
83
- const lastImport = matches[matches.length - 1];
84
- const lastImportEnd = lastImport.index + lastImport[0].length;
85
- const newCode = code.slice(0, lastImportEnd) + "\n\n" + codeToInject + "\n\n" + code.slice(lastImportEnd);
86
- return {
87
- code: newCode,
88
- map: null
89
- };
90
- }
91
- return {
92
- code: `${codeToInject}
93
-
94
- ${code}`,
95
- map: null
96
- };
30
+ function spawn(command, args = [], options = {}) {
31
+ return new Promise((resolve, reject) => {
32
+ const childProcess = spawn$1(command, args, {
33
+ // stdio: 'inherit',
34
+ ...options
35
+ });
36
+ childProcess.on("error", (error) => {
37
+ reject(error);
38
+ });
39
+ let stderr = "";
40
+ childProcess.stderr?.on("data", (message) => {
41
+ stderr += message;
42
+ });
43
+ childProcess.on("close", (code) => {
44
+ if (code === 0) {
45
+ resolve();
46
+ } else {
47
+ reject(new Error(stderr));
97
48
  }
98
- }
99
- };
49
+ });
50
+ });
51
+ }
52
+ function validate(file) {
53
+ return spawn("node", [
54
+ "--import",
55
+ import.meta.resolve("@mastra/deployer/loader"),
56
+ "--input-type=module",
57
+ "-e",
58
+ `import('file://${file.replaceAll("\\", "/")}')`
59
+ ]);
100
60
  }
101
61
 
102
62
  // src/build/analyze.ts
63
+ var globalExternals = ["pino", "pino-pretty", "@libsql/client"];
103
64
  async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
104
65
  logger.info("Analyzing dependencies...");
105
66
  let virtualPlugin = null;
@@ -109,10 +70,11 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
109
70
  });
110
71
  entry = "#entry";
111
72
  }
73
+ const normalizedMastraEntry = mastraEntry.replaceAll("\\", "/");
112
74
  const optimizerBundler = await rollup({
113
75
  logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
114
76
  input: isVirtualFile ? "#entry" : entry,
115
- treeshake: true,
77
+ treeshake: "smallest",
116
78
  preserveSymlinks: true,
117
79
  plugins: [
118
80
  virtualPlugin,
@@ -123,7 +85,7 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
123
85
  return fileURLToPath(import.meta.resolve("@mastra/deployer/server")).replaceAll("\\", "/");
124
86
  }
125
87
  if (id === "#mastra") {
126
- return mastraEntry.replaceAll("\\", "/");
88
+ return normalizedMastraEntry;
127
89
  }
128
90
  }
129
91
  },
@@ -139,7 +101,7 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
139
101
  transformMixedEsModules: true,
140
102
  extensions: [".js", ".ts"]
141
103
  }),
142
- removeDeployer(mastraEntry),
104
+ removeDeployer(normalizedMastraEntry),
143
105
  esbuild({
144
106
  target: "node20",
145
107
  platform,
@@ -200,7 +162,7 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
200
162
  ),
201
163
  // this dependency breaks the build, so we need to exclude it
202
164
  // TODO actually fix this so we don't need to exclude it
203
- external: ["jsdom"],
165
+ external: ["jsdom", ...globalExternals],
204
166
  treeshake: "smallest",
205
167
  preserveSymlinks: true,
206
168
  plugins: [
@@ -213,7 +175,6 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
213
175
  {}
214
176
  )
215
177
  ),
216
- pino(),
217
178
  commonjs({
218
179
  strictRequires: "strict",
219
180
  transformMixedEsModules: true,
@@ -244,6 +205,7 @@ async function validateOutput(output, reverseVirtualReferenceMap, outputDir, log
244
205
  dependencies: /* @__PURE__ */ new Map(),
245
206
  externalDependencies: /* @__PURE__ */ new Set()
246
207
  };
208
+ globalExternals.forEach((dep) => result.externalDependencies.add(dep));
247
209
  for (const file of output) {
248
210
  if (file.type === "asset") {
249
211
  continue;
@@ -253,7 +215,9 @@ async function validateOutput(output, reverseVirtualReferenceMap, outputDir, log
253
215
  if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
254
216
  result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
255
217
  }
256
- await import(`file:${outputDir}/${file.fileName}`);
218
+ if (!file.isDynamicEntry && file.isEntry) {
219
+ await validate(join(outputDir, file.fileName));
220
+ }
257
221
  } catch (err) {
258
222
  result.invalidChunks.add(file.fileName);
259
223
  if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
@@ -20,9 +20,21 @@ function removeDeployer() {
20
20
  state.hasReplaced = true;
21
21
  const newMastraObj = t.cloneNode(path.node);
22
22
  if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {
23
+ const deployer = newMastraObj.arguments[0].properties.find(
24
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
25
+ );
26
+ if (!deployer) {
27
+ return;
28
+ }
23
29
  newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(
24
- (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name !== "deployer"
30
+ (prop) => prop !== deployer
25
31
  );
32
+ if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {
33
+ const deployerBinding = state.file.scope.getBinding(deployer.value.name);
34
+ if (deployerBinding) {
35
+ deployerBinding?.path?.parentPath?.remove();
36
+ }
37
+ }
26
38
  path.replaceWith(newMastraObj);
27
39
  }
28
40
  }
@@ -41,9 +41,21 @@ function removeDeployer() {
41
41
  state.hasReplaced = true;
42
42
  const newMastraObj = t.cloneNode(path.node);
43
43
  if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {
44
+ const deployer = newMastraObj.arguments[0].properties.find(
45
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
46
+ );
47
+ if (!deployer) {
48
+ return;
49
+ }
44
50
  newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(
45
- (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name !== "deployer"
51
+ (prop) => prop !== deployer
46
52
  );
53
+ if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {
54
+ const deployerBinding = state.file.scope.getBinding(deployer.value.name);
55
+ if (deployerBinding) {
56
+ deployerBinding?.path?.parentPath?.remove();
57
+ }
58
+ }
47
59
  path.replaceWith(newMastraObj);
48
60
  }
49
61
  }
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkYLIG5BNH_cjs = require('./chunk-YLIG5BNH.cjs');
4
- var chunkQFYK5AS3_cjs = require('./chunk-QFYK5AS3.cjs');
5
- var chunk4LYFNYJ4_cjs = require('./chunk-4LYFNYJ4.cjs');
3
+ var chunkGLTC4BEQ_cjs = require('./chunk-GLTC4BEQ.cjs');
4
+ var chunk3H66SAKS_cjs = require('./chunk-3H66SAKS.cjs');
5
+ var chunkJSFQUYK4_cjs = require('./chunk-JSFQUYK4.cjs');
6
6
  var alias = require('@rollup/plugin-alias');
7
7
  var commonjs = require('@rollup/plugin-commonjs');
8
8
  var json = require('@rollup/plugin-json');
@@ -116,7 +116,7 @@ var FileService = class {
116
116
  * @returns
117
117
  */
118
118
  async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
119
- const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-YJMYF7RI.cjs', document.baseURI).href)));
119
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-PMHXFDK2.cjs', document.baseURI).href)));
120
120
  const __dirname = path__default.default.dirname(__filename);
121
121
  const filePath = path__default.default.resolve(__dirname, "..", "starter-files", inputFile);
122
122
  const fileString = fs2__namespace.default.readFileSync(filePath, "utf8");
@@ -174,7 +174,7 @@ function getOptions(inputOptions, platform, root) {
174
174
  return {
175
175
  logLevel: "silent",
176
176
  ...inputOptions,
177
- treeshake: false,
177
+ treeshake: "smallest",
178
178
  preserveSymlinks: true,
179
179
  external: [
180
180
  ...nodeBuiltins,
@@ -183,7 +183,6 @@ function getOptions(inputOptions, platform, root) {
183
183
  ],
184
184
  plugins: [
185
185
  ...inputOptions.plugins ?? [],
186
- chunkQFYK5AS3_cjs.telemetryFix(),
187
186
  alias__default.default({
188
187
  entries: [
189
188
  {
@@ -209,7 +208,6 @@ function getOptions(inputOptions, platform, root) {
209
208
  transformMixedEsModules: true
210
209
  // dynamicRequireTargets: ['node_modules/**/@libsql+win32-*/*'],
211
210
  }),
212
- chunkQFYK5AS3_cjs.libSqlFix(),
213
211
  // for debugging
214
212
  // {
215
213
  // name: 'logger',
@@ -229,7 +227,7 @@ function getOptions(inputOptions, platform, root) {
229
227
  "process.env.NODE_ENV": JSON.stringify("production")
230
228
  }
231
229
  }),
232
- chunk4LYFNYJ4_cjs.removeDeployer(entry),
230
+ chunkJSFQUYK4_cjs.removeDeployer(entry),
233
231
  esbuild__default.default({
234
232
  include: entry,
235
233
  target: "node20",
@@ -250,7 +248,7 @@ async function getWatcher(inputOptions, args = {}) {
250
248
  return watcher;
251
249
  }
252
250
  async function getInputOptions2(entryFile, platform) {
253
- const inputOptions = await chunkQFYK5AS3_cjs.getInputOptions(
251
+ const inputOptions = await chunk3H66SAKS_cjs.getInputOptions(
254
252
  entryFile,
255
253
  {
256
254
  dependencies: /* @__PURE__ */ new Map(),
@@ -264,7 +262,7 @@ async function getInputOptions2(entryFile, platform) {
264
262
  // @ts-ignore
265
263
  (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
266
264
  );
267
- inputOptions.plugins.push(chunkYLIG5BNH_cjs.aliasHono());
265
+ inputOptions.plugins.push(chunkGLTC4BEQ_cjs.aliasHono());
268
266
  }
269
267
  return inputOptions;
270
268
  }
@@ -199,7 +199,7 @@ var Deps = class extends base.MastraBase {
199
199
  }
200
200
  }
201
201
  async getPackageVersion() {
202
- const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-VPP5727D.cjs', document.baseURI).href)));
202
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-PRZC7CEM.cjs', document.baseURI).href)));
203
203
  const __dirname = path.dirname(__filename);
204
204
  const pkgJsonPath = path__default.default.join(__dirname, "..", "..", "package.json");
205
205
  const content = await fsExtra__default.default.readJSON(pkgJsonPath);
@@ -225,7 +225,7 @@ function removeAllExceptTelemetryConfig(result) {
225
225
  path2.remove();
226
226
  }
227
227
  },
228
- NewExpression(path2) {
228
+ NewExpression(path2, state) {
229
229
  const varDeclaratorPath = path2.findParent((path3) => t.isVariableDeclarator(path3.node));
230
230
  if (!varDeclaratorPath) {
231
231
  return;
@@ -234,23 +234,32 @@ function removeAllExceptTelemetryConfig(result) {
234
234
  if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
235
235
  return;
236
236
  }
237
- let telemetry = path2.node.arguments[0]?.properties?.find(
237
+ if (!t.isObjectExpression(path2.node.arguments[0]) || !path2.node.arguments[0].properties?.[0]) {
238
+ return;
239
+ }
240
+ let telemetry = path2.node.arguments[0].properties.find(
238
241
  // @ts-ignore
239
242
  (prop) => prop.key.name === "telemetry"
240
243
  );
244
+ let telemetryValue = t.objectExpression([]);
241
245
  const programPath = path2.scope.getProgramParent().path;
242
246
  if (!programPath) {
243
247
  return;
244
248
  }
245
- if (telemetry) {
249
+ if (telemetry && t.isObjectProperty(telemetry) && t.isExpression(telemetry.value)) {
246
250
  result.hasCustomConfig = true;
247
- } else {
248
- telemetry = {
249
- value: t.objectExpression([])
250
- };
251
+ telemetryValue = telemetry.value;
252
+ if (t.isIdentifier(telemetry.value) && telemetry.value.name === "telemetry") {
253
+ const telemetryBinding = state.file.scope.getBinding("telemetry");
254
+ if (telemetryBinding && t.isVariableDeclarator(telemetryBinding.path.node)) {
255
+ const id = path2.scope.generateUidIdentifier("telemetry");
256
+ telemetryBinding.path.replaceWith(t.variableDeclarator(id, telemetryBinding.path.node.init));
257
+ telemetryValue = id;
258
+ }
259
+ }
251
260
  }
252
261
  const exportDeclaration = t.exportNamedDeclaration(
253
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier("telemetry"), telemetry.value)]),
262
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier("telemetry"), telemetryValue)]),
254
263
  []
255
264
  );
256
265
  programPath.node.body.push(exportDeclaration);
@@ -258,11 +267,9 @@ function removeAllExceptTelemetryConfig(result) {
258
267
  }
259
268
  };
260
269
  }
261
- async function writeTelemetryConfig(entryFile, outputDir) {
262
- const result = {
263
- hasCustomConfig: false
264
- };
265
- const bundle = await rollup.rollup({
270
+ function getTelemetryBundler(entryFile, result) {
271
+ return rollup.rollup({
272
+ logLevel: "silent",
266
273
  input: {
267
274
  "telemetry-config": entryFile
268
275
  },
@@ -316,6 +323,12 @@ async function writeTelemetryConfig(entryFile, outputDir) {
316
323
  })
317
324
  ]
318
325
  });
326
+ }
327
+ async function writeTelemetryConfig(entryFile, outputDir) {
328
+ const result = {
329
+ hasCustomConfig: false
330
+ };
331
+ const bundle = await getTelemetryBundler(entryFile, result);
319
332
  await bundle.write({
320
333
  dir: outputDir,
321
334
  format: "es",
@@ -0,0 +1,128 @@
1
+ import { removeDeployer } from './chunk-JNNKML56.js';
2
+ import alias from '@rollup/plugin-alias';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import json from '@rollup/plugin-json';
5
+ import nodeResolve from '@rollup/plugin-node-resolve';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { rollup } from 'rollup';
8
+ import esbuild from 'rollup-plugin-esbuild';
9
+
10
+ async function getInputOptions(entryFile, analyzedBundleInfo, platform) {
11
+ let nodeResolvePlugin = platform === "node" ? nodeResolve({
12
+ preferBuiltins: true,
13
+ exportConditions: ["node", "import", "require"],
14
+ mainFields: ["module", "main"]
15
+ }) : nodeResolve({
16
+ preferBuiltins: false,
17
+ exportConditions: ["browser", "import", "require"],
18
+ mainFields: ["module", "main"],
19
+ browser: true
20
+ });
21
+ const externalsCopy = /* @__PURE__ */ new Set();
22
+ for (const external of analyzedBundleInfo.externalDependencies) {
23
+ if (external.startsWith("@")) {
24
+ const [scope, name] = external.split("/", 3);
25
+ externalsCopy.add(`${scope}/${name}`);
26
+ externalsCopy.add(`${scope}/${name}/*`);
27
+ } else {
28
+ externalsCopy.add(external);
29
+ externalsCopy.add(`${external}/*`);
30
+ }
31
+ }
32
+ const externals = Array.from(externalsCopy);
33
+ const normalizedEntryFile = entryFile.replaceAll("\\", "/");
34
+ return {
35
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
36
+ treeshake: "smallest",
37
+ preserveSymlinks: true,
38
+ external: externals,
39
+ plugins: [
40
+ {
41
+ name: "alias-optimized-deps",
42
+ // @ts-ignore
43
+ resolveId(id) {
44
+ if (!analyzedBundleInfo.dependencies.has(id)) {
45
+ return null;
46
+ }
47
+ const isInvalidChunk = analyzedBundleInfo.invalidChunks.has(analyzedBundleInfo.dependencies.get(id));
48
+ if (isInvalidChunk) {
49
+ return {
50
+ id,
51
+ external: true
52
+ };
53
+ }
54
+ return {
55
+ id: ".mastra/.build/" + analyzedBundleInfo.dependencies.get(id),
56
+ external: false
57
+ };
58
+ }
59
+ },
60
+ alias({
61
+ entries: [
62
+ {
63
+ find: /^\#server$/,
64
+ replacement: fileURLToPath(import.meta.resolve("@mastra/deployer/server")).replaceAll("\\", "/")
65
+ },
66
+ { find: /^\#mastra$/, replacement: normalizedEntryFile }
67
+ ]
68
+ }),
69
+ esbuild({
70
+ target: "node20",
71
+ platform,
72
+ minify: false,
73
+ define: {
74
+ "process.env.NODE_ENV": JSON.stringify("production")
75
+ }
76
+ }),
77
+ commonjs({
78
+ extensions: [".js", ".ts"],
79
+ transformMixedEsModules: true,
80
+ esmExternals(id) {
81
+ return externals.includes(id);
82
+ }
83
+ }),
84
+ nodeResolvePlugin,
85
+ // for debugging
86
+ // {
87
+ // name: 'logger',
88
+ // //@ts-ignore
89
+ // resolveId(id, ...args) {
90
+ // console.log({ id, args });
91
+ // },
92
+ // // @ts-ignore
93
+ // transform(code, id) {
94
+ // if (code.includes('class Duplexify ')) {
95
+ // console.log({ duplex: id });
96
+ // }
97
+ // },
98
+ // },
99
+ json(),
100
+ removeDeployer(entryFile),
101
+ // treeshake unused imports
102
+ esbuild({
103
+ include: entryFile,
104
+ target: "node20",
105
+ platform,
106
+ minify: false
107
+ })
108
+ ].filter(Boolean)
109
+ };
110
+ }
111
+ async function createBundler(inputOptions, outputOptions) {
112
+ const bundler = await rollup(inputOptions);
113
+ return {
114
+ write: () => {
115
+ return bundler.write({
116
+ ...outputOptions,
117
+ format: "esm",
118
+ entryFileNames: "[name].mjs",
119
+ chunkFileNames: "[name].mjs"
120
+ });
121
+ },
122
+ close: () => {
123
+ return bundler.close();
124
+ }
125
+ };
126
+ }
127
+
128
+ export { createBundler, getInputOptions };
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkYJMYF7RI_cjs = require('./chunk-YJMYF7RI.cjs');
4
- var chunkJ2F3DJTF_cjs = require('./chunk-J2F3DJTF.cjs');
5
- var chunkVPP5727D_cjs = require('./chunk-VPP5727D.cjs');
3
+ var chunkPMHXFDK2_cjs = require('./chunk-PMHXFDK2.cjs');
4
+ var chunkHLGZCQQW_cjs = require('./chunk-HLGZCQQW.cjs');
5
+ var chunkPRZC7CEM_cjs = require('./chunk-PRZC7CEM.cjs');
6
6
  var babel = require('@babel/core');
7
7
  var rollup = require('rollup');
8
8
  var esbuild = require('rollup-plugin-esbuild');
@@ -33,8 +33,8 @@ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
33
33
  var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
34
34
 
35
35
  // src/deploy/base.ts
36
- var Deployer = class extends chunkJ2F3DJTF_cjs.Bundler {
37
- deps = new chunkVPP5727D_cjs.Deps();
36
+ var Deployer = class extends chunkHLGZCQQW_cjs.Bundler {
37
+ deps = new chunkPRZC7CEM_cjs.Deps();
38
38
  constructor(args) {
39
39
  super(args.name, "DEPLOYER");
40
40
  this.deps.__setLogger(this.logger);
@@ -42,7 +42,7 @@ var Deployer = class extends chunkJ2F3DJTF_cjs.Bundler {
42
42
  getEnvFiles() {
43
43
  const possibleFiles = [".env.production", ".env.local", ".env"];
44
44
  try {
45
- const fileService = new chunkYJMYF7RI_cjs.FileService();
45
+ const fileService = new chunkPMHXFDK2_cjs.FileService();
46
46
  const envFile = fileService.getFirstExistingFile(possibleFiles);
47
47
  return Promise.resolve([envFile]);
48
48
  } catch {
@@ -87,8 +87,9 @@ function removeAllExceptDeployer() {
87
87
  }
88
88
  };
89
89
  }
90
- async function getDeployer(entryFile, outputDir) {
91
- const bundle = await rollup.rollup({
90
+ function getDeployerBundler(entryFile) {
91
+ return rollup.rollup({
92
+ logLevel: "silent",
92
93
  input: {
93
94
  deployer: entryFile
94
95
  },
@@ -142,6 +143,9 @@ async function getDeployer(entryFile, outputDir) {
142
143
  })
143
144
  ]
144
145
  });
146
+ }
147
+ async function getDeployer(entryFile, outputDir) {
148
+ const bundle = await getDeployerBundler(entryFile);
145
149
  await bundle.write({
146
150
  dir: outputDir,
147
151
  format: "es",
@@ -152,19 +156,19 @@ async function getDeployer(entryFile, outputDir) {
152
156
 
153
157
  Object.defineProperty(exports, "FileService", {
154
158
  enumerable: true,
155
- get: function () { return chunkYJMYF7RI_cjs.FileService; }
159
+ get: function () { return chunkPMHXFDK2_cjs.FileService; }
156
160
  });
157
161
  Object.defineProperty(exports, "Deps", {
158
162
  enumerable: true,
159
- get: function () { return chunkVPP5727D_cjs.Deps; }
163
+ get: function () { return chunkPRZC7CEM_cjs.Deps; }
160
164
  });
161
165
  Object.defineProperty(exports, "createChildProcessLogger", {
162
166
  enumerable: true,
163
- get: function () { return chunkVPP5727D_cjs.createChildProcessLogger; }
167
+ get: function () { return chunkPRZC7CEM_cjs.createChildProcessLogger; }
164
168
  });
165
169
  Object.defineProperty(exports, "createPinoStream", {
166
170
  enumerable: true,
167
- get: function () { return chunkVPP5727D_cjs.createPinoStream; }
171
+ get: function () { return chunkPRZC7CEM_cjs.createPinoStream; }
168
172
  });
169
173
  exports.Deployer = Deployer;
170
174
  exports.getDeployer = getDeployer;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { FileService } from './chunk-72GFPLLU.js';
2
- export { FileService } from './chunk-72GFPLLU.js';
3
- import { Bundler } from './chunk-VPY2RQUP.js';
4
- import { Deps } from './chunk-SL5KZNFT.js';
5
- export { Deps, createChildProcessLogger, createPinoStream } from './chunk-SL5KZNFT.js';
1
+ import { FileService } from './chunk-DZ4D3KXZ.js';
2
+ export { FileService } from './chunk-DZ4D3KXZ.js';
3
+ import { Bundler } from './chunk-HRR4D2GM.js';
4
+ import { Deps } from './chunk-7XQJJPRM.js';
5
+ export { Deps, createChildProcessLogger, createPinoStream } from './chunk-7XQJJPRM.js';
6
6
  import * as babel from '@babel/core';
7
7
  import babel__default from '@babel/core';
8
8
  import { rollup } from 'rollup';
@@ -64,8 +64,9 @@ function removeAllExceptDeployer() {
64
64
  }
65
65
  };
66
66
  }
67
- async function getDeployer(entryFile, outputDir) {
68
- const bundle = await rollup({
67
+ function getDeployerBundler(entryFile) {
68
+ return rollup({
69
+ logLevel: "silent",
69
70
  input: {
70
71
  deployer: entryFile
71
72
  },
@@ -119,6 +120,9 @@ async function getDeployer(entryFile, outputDir) {
119
120
  })
120
121
  ]
121
122
  });
123
+ }
124
+ async function getDeployer(entryFile, outputDir) {
125
+ const bundle = await getDeployerBundler(entryFile);
122
126
  await bundle.write({
123
127
  dir: outputDir,
124
128
  format: "es",