@mastra/deployer 0.10.6-alpha.3 → 0.10.6-alpha.5
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.
- package/dist/_tsup-dts-rollup.d.cts +2 -2
- package/dist/_tsup-dts-rollup.d.ts +2 -2
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/index.cjs +9 -9
- package/dist/build/index.js +3 -3
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-FBZWTLPQ.js → chunk-72MENR23.js} +111 -43
- package/dist/{chunk-TSG63RGL.cjs → chunk-F4JNMQTU.cjs} +14 -3
- package/dist/{chunk-DTQ7BTPM.cjs → chunk-IFU2DUSR.cjs} +3 -3
- package/dist/{chunk-WGJTOVLL.js → chunk-J2V6UIZO.js} +14 -3
- package/dist/{chunk-EXHFPVZH.js → chunk-KJINZD6K.js} +1 -1
- package/dist/{chunk-G7OBNEAD.js → chunk-MGULNF6D.js} +1 -1
- package/dist/{chunk-VZ6L36CW.cjs → chunk-QGO33MM3.cjs} +113 -45
- package/dist/{chunk-DBEMB6OV.cjs → chunk-UTZFG7JQ.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/package.json +4 -4
|
@@ -41,7 +41,7 @@ export declare function aliasHono(): Plugin;
|
|
|
41
41
|
*
|
|
42
42
|
* This helps identify which dependencies need to be externalized vs bundled.
|
|
43
43
|
*/
|
|
44
|
-
declare function analyzeBundle(
|
|
44
|
+
declare function analyzeBundle(entries: string[], mastraEntry: string, outputDir: string, platform: 'node' | 'browser', logger: IMastraLogger): Promise<{
|
|
45
45
|
invalidChunks: Set<string>;
|
|
46
46
|
dependencies: Map<string, string>;
|
|
47
47
|
externalDependencies: Set<string>;
|
|
@@ -87,7 +87,7 @@ export declare abstract class Bundler extends MastraBundler {
|
|
|
87
87
|
write: () => Promise<RollupOutput>;
|
|
88
88
|
close: () => Promise<void>;
|
|
89
89
|
}>;
|
|
90
|
-
protected analyze(entry: string, mastraFile: string, outputDirectory: string): Promise<{
|
|
90
|
+
protected analyze(entry: string | string[], mastraFile: string, outputDirectory: string): Promise<{
|
|
91
91
|
invalidChunks: Set<string>;
|
|
92
92
|
dependencies: Map<string, string>;
|
|
93
93
|
externalDependencies: Set<string>;
|
|
@@ -41,7 +41,7 @@ export declare function aliasHono(): Plugin;
|
|
|
41
41
|
*
|
|
42
42
|
* This helps identify which dependencies need to be externalized vs bundled.
|
|
43
43
|
*/
|
|
44
|
-
declare function analyzeBundle(
|
|
44
|
+
declare function analyzeBundle(entries: string[], mastraEntry: string, outputDir: string, platform: 'node' | 'browser', logger: IMastraLogger): Promise<{
|
|
45
45
|
invalidChunks: Set<string>;
|
|
46
46
|
dependencies: Map<string, string>;
|
|
47
47
|
externalDependencies: Set<string>;
|
|
@@ -87,7 +87,7 @@ export declare abstract class Bundler extends MastraBundler {
|
|
|
87
87
|
write: () => Promise<RollupOutput>;
|
|
88
88
|
close: () => Promise<void>;
|
|
89
89
|
}>;
|
|
90
|
-
protected analyze(entry: string, mastraFile: string, outputDirectory: string): Promise<{
|
|
90
|
+
protected analyze(entry: string | string[], mastraFile: string, outputDirectory: string): Promise<{
|
|
91
91
|
invalidChunks: Set<string>;
|
|
92
92
|
dependencies: Map<string, string>;
|
|
93
93
|
externalDependencies: Set<string>;
|
package/dist/build/analyze.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkF4JNMQTU_cjs = require('../chunk-F4JNMQTU.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "analyzeBundle", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkF4JNMQTU_cjs.analyzeBundle; }
|
|
10
10
|
});
|
package/dist/build/analyze.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { analyzeBundle } from '../chunk-
|
|
1
|
+
export { analyzeBundle } from '../chunk-J2V6UIZO.js';
|
package/dist/build/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkUTZFG7JQ_cjs = require('../chunk-UTZFG7JQ.cjs');
|
|
4
|
+
var chunkIFU2DUSR_cjs = require('../chunk-IFU2DUSR.cjs');
|
|
5
|
+
var chunkF4JNMQTU_cjs = require('../chunk-F4JNMQTU.cjs');
|
|
6
6
|
var chunkIMGVLBV7_cjs = require('../chunk-IMGVLBV7.cjs');
|
|
7
7
|
var chunk7ICGDVC3_cjs = require('../chunk-7ICGDVC3.cjs');
|
|
8
8
|
|
|
@@ -10,27 +10,27 @@ var chunk7ICGDVC3_cjs = require('../chunk-7ICGDVC3.cjs');
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "createWatcher", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkUTZFG7JQ_cjs.createWatcher; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getServerOptions", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkUTZFG7JQ_cjs.getServerOptions; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "getWatcherInputOptions", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkUTZFG7JQ_cjs.getInputOptions; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "writeTelemetryConfig", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkIFU2DUSR_cjs.writeTelemetryConfig; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "analyzeBundle", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkF4JNMQTU_cjs.analyzeBundle; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "getBundlerOptions", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkF4JNMQTU_cjs.getBundlerOptions; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "createBundler", {
|
|
36
36
|
enumerable: true,
|
package/dist/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-
|
|
2
|
-
export { writeTelemetryConfig } from '../chunk-
|
|
3
|
-
export { analyzeBundle, getBundlerOptions } from '../chunk-
|
|
1
|
+
export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-MGULNF6D.js';
|
|
2
|
+
export { writeTelemetryConfig } from '../chunk-KJINZD6K.js';
|
|
3
|
+
export { analyzeBundle, getBundlerOptions } from '../chunk-J2V6UIZO.js';
|
|
4
4
|
export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-HHOCIHND.js';
|
|
5
5
|
export { Deps, FileService } from '../chunk-4VKGIENI.js';
|
package/dist/bundler/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQGO33MM3_cjs = require('../chunk-QGO33MM3.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "Bundler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkQGO33MM3_cjs.Bundler; }
|
|
10
10
|
});
|
package/dist/bundler/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Bundler } from '../chunk-
|
|
1
|
+
export { Bundler } from '../chunk-72MENR23.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { writeTelemetryConfig } from './chunk-
|
|
2
|
-
import { analyzeBundle } from './chunk-
|
|
1
|
+
import { writeTelemetryConfig } from './chunk-KJINZD6K.js';
|
|
2
|
+
import { analyzeBundle } from './chunk-J2V6UIZO.js';
|
|
3
3
|
import { createBundler, getInputOptions } from './chunk-HHOCIHND.js';
|
|
4
4
|
import { DepsService, FileService } from './chunk-4VKGIENI.js';
|
|
5
5
|
import { existsSync } from 'fs';
|
|
@@ -7,6 +7,7 @@ import { writeFile, stat } from 'fs/promises';
|
|
|
7
7
|
import { join, dirname } from 'path';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
9
|
import { MastraBundler } from '@mastra/core/bundler';
|
|
10
|
+
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
10
11
|
import virtual from '@rollup/plugin-virtual';
|
|
11
12
|
import fsExtra, { emptyDir, ensureDir, copy, readJSON } from 'fs-extra/esm';
|
|
12
13
|
import { globby } from 'globby';
|
|
@@ -95,11 +96,7 @@ var packWorkspaceDependencies = async ({
|
|
|
95
96
|
batch.map(async (pkgName) => {
|
|
96
97
|
const dep = workspaceMap.get(pkgName);
|
|
97
98
|
if (!dep) return;
|
|
98
|
-
|
|
99
|
-
await depsService.pack({ dir: dep.location, destination: workspaceDirPath });
|
|
100
|
-
} catch (error) {
|
|
101
|
-
logger.error(`Failed to package ${pkgName}: ${error}`);
|
|
102
|
-
}
|
|
99
|
+
await depsService.pack({ dir: dep.location, destination: workspaceDirPath });
|
|
103
100
|
})
|
|
104
101
|
);
|
|
105
102
|
}
|
|
@@ -176,7 +173,13 @@ var Bundler = class extends MastraBundler {
|
|
|
176
173
|
return createBundler(inputOptions, outputOptions);
|
|
177
174
|
}
|
|
178
175
|
async analyze(entry, mastraFile, outputDirectory) {
|
|
179
|
-
return await analyzeBundle(
|
|
176
|
+
return await analyzeBundle(
|
|
177
|
+
[].concat(entry),
|
|
178
|
+
mastraFile,
|
|
179
|
+
join(outputDirectory, this.analyzeOutputDir),
|
|
180
|
+
"node",
|
|
181
|
+
this.logger
|
|
182
|
+
);
|
|
180
183
|
}
|
|
181
184
|
async installDependencies(outputDirectory, rootDir = process.cwd()) {
|
|
182
185
|
const deps = new DepsService(rootDir);
|
|
@@ -238,14 +241,44 @@ var Bundler = class extends MastraBundler {
|
|
|
238
241
|
}
|
|
239
242
|
async _bundle(serverFile, mastraEntryFile, outputDirectory, toolsPaths = [], bundleLocation = join(outputDirectory, this.outputDir)) {
|
|
240
243
|
this.logger.info("Start bundling Mastra");
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
let analyzedBundleInfo;
|
|
245
|
+
try {
|
|
246
|
+
const resolvedToolsPaths = await this.getToolsInputOptions(toolsPaths);
|
|
247
|
+
analyzedBundleInfo = await analyzeBundle(
|
|
248
|
+
[serverFile, ...Object.values(resolvedToolsPaths)],
|
|
249
|
+
mastraEntryFile,
|
|
250
|
+
join(outputDirectory, this.analyzeOutputDir),
|
|
251
|
+
"node",
|
|
252
|
+
this.logger
|
|
253
|
+
);
|
|
254
|
+
} catch (error) {
|
|
255
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
256
|
+
throw new MastraError(
|
|
257
|
+
{
|
|
258
|
+
id: "DEPLOYER_BUNDLER_ANALYZE_FAILED",
|
|
259
|
+
text: `Failed to analyze Mastra application: ${message}`,
|
|
260
|
+
domain: ErrorDomain.DEPLOYER,
|
|
261
|
+
category: ErrorCategory.SYSTEM
|
|
262
|
+
},
|
|
263
|
+
error
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
let externalDependencies;
|
|
267
|
+
try {
|
|
268
|
+
const result = await writeTelemetryConfig(mastraEntryFile, join(outputDirectory, this.outputDir));
|
|
269
|
+
externalDependencies = result.externalDependencies;
|
|
270
|
+
} catch (error) {
|
|
271
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
272
|
+
throw new MastraError(
|
|
273
|
+
{
|
|
274
|
+
id: "DEPLOYER_BUNDLER_TELEMETRY_FAILED",
|
|
275
|
+
text: `Failed to write telemetry config: ${message}`,
|
|
276
|
+
domain: ErrorDomain.DEPLOYER,
|
|
277
|
+
category: ErrorCategory.SYSTEM
|
|
278
|
+
},
|
|
279
|
+
error
|
|
280
|
+
);
|
|
281
|
+
}
|
|
249
282
|
const dependenciesToInstall = /* @__PURE__ */ new Map();
|
|
250
283
|
for (const external of externalDependencies) {
|
|
251
284
|
dependenciesToInstall.set(external, "latest");
|
|
@@ -284,35 +317,70 @@ var Bundler = class extends MastraBundler {
|
|
|
284
317
|
logger: this.logger
|
|
285
318
|
});
|
|
286
319
|
} catch (error) {
|
|
287
|
-
|
|
288
|
-
|
|
320
|
+
throw new MastraError(
|
|
321
|
+
{
|
|
322
|
+
id: "DEPLOYER_BUNDLER_WORKSPACE_DEPS_FAILED",
|
|
323
|
+
text: `Failed to collect and pack workspace dependencies.`,
|
|
324
|
+
domain: ErrorDomain.DEPLOYER,
|
|
325
|
+
category: ErrorCategory.USER
|
|
326
|
+
},
|
|
327
|
+
error
|
|
328
|
+
);
|
|
289
329
|
}
|
|
290
330
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
331
|
+
try {
|
|
332
|
+
await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall, resolutions);
|
|
333
|
+
await this.writeInstrumentationFile(join(outputDirectory, this.outputDir));
|
|
334
|
+
this.logger.info("Bundling Mastra application");
|
|
335
|
+
const inputOptions = await this.getBundlerOptions(
|
|
336
|
+
serverFile,
|
|
337
|
+
mastraEntryFile,
|
|
338
|
+
analyzedBundleInfo,
|
|
339
|
+
toolsPaths
|
|
340
|
+
);
|
|
341
|
+
const bundler = await this.createBundler(
|
|
342
|
+
{
|
|
343
|
+
...inputOptions,
|
|
344
|
+
logLevel: inputOptions.logLevel === "silent" ? "warn" : inputOptions.logLevel,
|
|
345
|
+
onwarn: (warning) => {
|
|
346
|
+
if (warning.code === "CIRCULAR_DEPENDENCY") {
|
|
347
|
+
if (warning.ids?.[0]?.includes("node_modules")) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
this.logger.warn(`Circular dependency found:
|
|
351
|
+
${warning.message.replace("Circular dependency: ", "")}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
dir: bundleLocation,
|
|
357
|
+
manualChunks: {
|
|
358
|
+
mastra: ["#mastra"]
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
await bundler.write();
|
|
363
|
+
const toolsInputOptions = Array.from(Object.keys(inputOptions.input || {})).filter((key) => key.startsWith("tools/")).map((key) => `./${key}.mjs`);
|
|
364
|
+
await writeFile(join(bundleLocation, "tools.mjs"), `export const tools = ${JSON.stringify(toolsInputOptions)};`);
|
|
365
|
+
this.logger.info("Bundling Mastra done");
|
|
366
|
+
this.logger.info("Copying public files");
|
|
367
|
+
await this.copyPublic(dirname(mastraEntryFile), outputDirectory);
|
|
368
|
+
this.logger.info("Done copying public files");
|
|
369
|
+
this.logger.info("Installing dependencies");
|
|
370
|
+
await this.installDependencies(outputDirectory);
|
|
371
|
+
this.logger.info("Done installing dependencies");
|
|
372
|
+
} catch (error) {
|
|
373
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
374
|
+
throw new MastraError(
|
|
375
|
+
{
|
|
376
|
+
id: "DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED",
|
|
377
|
+
text: `Failed during bundler bundle stage: ${message}`,
|
|
378
|
+
domain: ErrorDomain.DEPLOYER,
|
|
379
|
+
category: ErrorCategory.SYSTEM
|
|
380
|
+
},
|
|
381
|
+
error
|
|
382
|
+
);
|
|
383
|
+
}
|
|
316
384
|
}
|
|
317
385
|
async lint(_entryFile, _outputDirectory, toolsPaths) {
|
|
318
386
|
const toolsInputOptions = await this.getToolsInputOptions(toolsPaths);
|
|
@@ -561,9 +561,20 @@ async function validateOutput({
|
|
|
561
561
|
}
|
|
562
562
|
return result;
|
|
563
563
|
}
|
|
564
|
-
async function analyzeBundle(
|
|
565
|
-
const
|
|
566
|
-
const
|
|
564
|
+
async function analyzeBundle(entries, mastraEntry, outputDir, platform, logger) {
|
|
565
|
+
const depsToOptimize = /* @__PURE__ */ new Map();
|
|
566
|
+
for (const entry of entries) {
|
|
567
|
+
const isVirtualFile = entry.includes("\n") || !fs.existsSync(entry);
|
|
568
|
+
const analyzeResult = await analyze(entry, mastraEntry, isVirtualFile, platform, logger);
|
|
569
|
+
for (const [dep, exports] of analyzeResult.entries()) {
|
|
570
|
+
if (depsToOptimize.has(dep)) {
|
|
571
|
+
const existingExports = depsToOptimize.get(dep);
|
|
572
|
+
depsToOptimize.set(dep, [.../* @__PURE__ */ new Set([...existingExports, ...exports])]);
|
|
573
|
+
} else {
|
|
574
|
+
depsToOptimize.set(dep, exports);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
567
578
|
const customExternals = (await getBundlerOptions(mastraEntry, outputDir))?.externals;
|
|
568
579
|
const { output, reverseVirtualReferenceMap, usedExternals } = await bundleExternals(
|
|
569
580
|
depsToOptimize,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkF4JNMQTU_cjs = require('./chunk-F4JNMQTU.cjs');
|
|
4
4
|
var babel = require('@babel/core');
|
|
5
5
|
var rollup = require('rollup');
|
|
6
6
|
var esbuild = require('rollup-plugin-esbuild');
|
|
@@ -32,7 +32,7 @@ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
|
|
32
32
|
|
|
33
33
|
// src/build/babel/remove-all-options-telemetry.ts
|
|
34
34
|
function removeAllOptionsExceptTelemetry(result) {
|
|
35
|
-
return
|
|
35
|
+
return chunkF4JNMQTU_cjs.removeAllOptionsFromMastraExcept(result, "telemetry");
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// src/build/telemetry.ts
|
|
@@ -96,7 +96,7 @@ function getTelemetryBundler(entryFile, result) {
|
|
|
96
96
|
if (id !== entryFile) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
return
|
|
99
|
+
return chunkF4JNMQTU_cjs.recursiveRemoveNonReferencedNodes(code);
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
// let esbuild remove all unused imports
|
|
@@ -533,9 +533,20 @@ async function validateOutput({
|
|
|
533
533
|
}
|
|
534
534
|
return result;
|
|
535
535
|
}
|
|
536
|
-
async function analyzeBundle(
|
|
537
|
-
const
|
|
538
|
-
const
|
|
536
|
+
async function analyzeBundle(entries, mastraEntry, outputDir, platform, logger) {
|
|
537
|
+
const depsToOptimize = /* @__PURE__ */ new Map();
|
|
538
|
+
for (const entry of entries) {
|
|
539
|
+
const isVirtualFile = entry.includes("\n") || !existsSync(entry);
|
|
540
|
+
const analyzeResult = await analyze(entry, mastraEntry, isVirtualFile, platform, logger);
|
|
541
|
+
for (const [dep, exports] of analyzeResult.entries()) {
|
|
542
|
+
if (depsToOptimize.has(dep)) {
|
|
543
|
+
const existingExports = depsToOptimize.get(dep);
|
|
544
|
+
depsToOptimize.set(dep, [.../* @__PURE__ */ new Set([...existingExports, ...exports])]);
|
|
545
|
+
} else {
|
|
546
|
+
depsToOptimize.set(dep, exports);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
539
550
|
const customExternals = (await getBundlerOptions(mastraEntry, outputDir))?.externals;
|
|
540
551
|
const { output, reverseVirtualReferenceMap, usedExternals } = await bundleExternals(
|
|
541
552
|
depsToOptimize,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-
|
|
1
|
+
import { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-J2V6UIZO.js';
|
|
2
2
|
import * as babel from '@babel/core';
|
|
3
3
|
import { rollup } from 'rollup';
|
|
4
4
|
import esbuild from 'rollup-plugin-esbuild';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aliasHono, recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-
|
|
1
|
+
import { aliasHono, recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-J2V6UIZO.js';
|
|
2
2
|
import { getInputOptions } from './chunk-HHOCIHND.js';
|
|
3
3
|
import { tsConfigPaths } from './chunk-Z544XXXK.js';
|
|
4
4
|
import { watch, rollup } from 'rollup';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkIFU2DUSR_cjs = require('./chunk-IFU2DUSR.cjs');
|
|
4
|
+
var chunkF4JNMQTU_cjs = require('./chunk-F4JNMQTU.cjs');
|
|
5
5
|
var chunkIMGVLBV7_cjs = require('./chunk-IMGVLBV7.cjs');
|
|
6
6
|
var chunk7ICGDVC3_cjs = require('./chunk-7ICGDVC3.cjs');
|
|
7
7
|
var fs = require('fs');
|
|
@@ -9,6 +9,7 @@ var promises = require('fs/promises');
|
|
|
9
9
|
var path = require('path');
|
|
10
10
|
var url = require('url');
|
|
11
11
|
var bundler = require('@mastra/core/bundler');
|
|
12
|
+
var error = require('@mastra/core/error');
|
|
12
13
|
var virtual = require('@rollup/plugin-virtual');
|
|
13
14
|
var fsExtra = require('fs-extra/esm');
|
|
14
15
|
var globby = require('globby');
|
|
@@ -105,11 +106,7 @@ var packWorkspaceDependencies = async ({
|
|
|
105
106
|
batch.map(async (pkgName) => {
|
|
106
107
|
const dep = workspaceMap.get(pkgName);
|
|
107
108
|
if (!dep) return;
|
|
108
|
-
|
|
109
|
-
await depsService.pack({ dir: dep.location, destination: workspaceDirPath });
|
|
110
|
-
} catch (error) {
|
|
111
|
-
logger.error(`Failed to package ${pkgName}: ${error}`);
|
|
112
|
-
}
|
|
109
|
+
await depsService.pack({ dir: dep.location, destination: workspaceDirPath });
|
|
113
110
|
})
|
|
114
111
|
);
|
|
115
112
|
}
|
|
@@ -131,7 +128,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
131
128
|
}
|
|
132
129
|
async writeInstrumentationFile(outputDirectory) {
|
|
133
130
|
const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
134
|
-
const __dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
131
|
+
const __dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-QGO33MM3.cjs', document.baseURI).href))));
|
|
135
132
|
await fsExtra.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
|
|
136
133
|
}
|
|
137
134
|
async writePackageJson(outputDirectory, dependencies, resolutions) {
|
|
@@ -186,7 +183,13 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
186
183
|
return chunkIMGVLBV7_cjs.createBundler(inputOptions, outputOptions);
|
|
187
184
|
}
|
|
188
185
|
async analyze(entry, mastraFile, outputDirectory) {
|
|
189
|
-
return await
|
|
186
|
+
return await chunkF4JNMQTU_cjs.analyzeBundle(
|
|
187
|
+
[].concat(entry),
|
|
188
|
+
mastraFile,
|
|
189
|
+
path.join(outputDirectory, this.analyzeOutputDir),
|
|
190
|
+
"node",
|
|
191
|
+
this.logger
|
|
192
|
+
);
|
|
190
193
|
}
|
|
191
194
|
async installDependencies(outputDirectory, rootDir = process.cwd()) {
|
|
192
195
|
const deps = new chunk7ICGDVC3_cjs.DepsService(rootDir);
|
|
@@ -248,14 +251,44 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
248
251
|
}
|
|
249
252
|
async _bundle(serverFile, mastraEntryFile, outputDirectory, toolsPaths = [], bundleLocation = path.join(outputDirectory, this.outputDir)) {
|
|
250
253
|
this.logger.info("Start bundling Mastra");
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
let analyzedBundleInfo;
|
|
255
|
+
try {
|
|
256
|
+
const resolvedToolsPaths = await this.getToolsInputOptions(toolsPaths);
|
|
257
|
+
analyzedBundleInfo = await chunkF4JNMQTU_cjs.analyzeBundle(
|
|
258
|
+
[serverFile, ...Object.values(resolvedToolsPaths)],
|
|
259
|
+
mastraEntryFile,
|
|
260
|
+
path.join(outputDirectory, this.analyzeOutputDir),
|
|
261
|
+
"node",
|
|
262
|
+
this.logger
|
|
263
|
+
);
|
|
264
|
+
} catch (error$1) {
|
|
265
|
+
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
266
|
+
throw new error.MastraError(
|
|
267
|
+
{
|
|
268
|
+
id: "DEPLOYER_BUNDLER_ANALYZE_FAILED",
|
|
269
|
+
text: `Failed to analyze Mastra application: ${message}`,
|
|
270
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
271
|
+
category: error.ErrorCategory.SYSTEM
|
|
272
|
+
},
|
|
273
|
+
error$1
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
let externalDependencies;
|
|
277
|
+
try {
|
|
278
|
+
const result = await chunkIFU2DUSR_cjs.writeTelemetryConfig(mastraEntryFile, path.join(outputDirectory, this.outputDir));
|
|
279
|
+
externalDependencies = result.externalDependencies;
|
|
280
|
+
} catch (error$1) {
|
|
281
|
+
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
282
|
+
throw new error.MastraError(
|
|
283
|
+
{
|
|
284
|
+
id: "DEPLOYER_BUNDLER_TELEMETRY_FAILED",
|
|
285
|
+
text: `Failed to write telemetry config: ${message}`,
|
|
286
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
287
|
+
category: error.ErrorCategory.SYSTEM
|
|
288
|
+
},
|
|
289
|
+
error$1
|
|
290
|
+
);
|
|
291
|
+
}
|
|
259
292
|
const dependenciesToInstall = /* @__PURE__ */ new Map();
|
|
260
293
|
for (const external of externalDependencies) {
|
|
261
294
|
dependenciesToInstall.set(external, "latest");
|
|
@@ -293,36 +326,71 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
293
326
|
bundleOutputDir: path.join(outputDirectory, this.outputDir),
|
|
294
327
|
logger: this.logger
|
|
295
328
|
});
|
|
296
|
-
} catch (error) {
|
|
297
|
-
|
|
298
|
-
|
|
329
|
+
} catch (error$1) {
|
|
330
|
+
throw new error.MastraError(
|
|
331
|
+
{
|
|
332
|
+
id: "DEPLOYER_BUNDLER_WORKSPACE_DEPS_FAILED",
|
|
333
|
+
text: `Failed to collect and pack workspace dependencies.`,
|
|
334
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
335
|
+
category: error.ErrorCategory.USER
|
|
336
|
+
},
|
|
337
|
+
error$1
|
|
338
|
+
);
|
|
299
339
|
}
|
|
300
340
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
341
|
+
try {
|
|
342
|
+
await this.writePackageJson(path.join(outputDirectory, this.outputDir), dependenciesToInstall, resolutions);
|
|
343
|
+
await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir));
|
|
344
|
+
this.logger.info("Bundling Mastra application");
|
|
345
|
+
const inputOptions = await this.getBundlerOptions(
|
|
346
|
+
serverFile,
|
|
347
|
+
mastraEntryFile,
|
|
348
|
+
analyzedBundleInfo,
|
|
349
|
+
toolsPaths
|
|
350
|
+
);
|
|
351
|
+
const bundler = await this.createBundler(
|
|
352
|
+
{
|
|
353
|
+
...inputOptions,
|
|
354
|
+
logLevel: inputOptions.logLevel === "silent" ? "warn" : inputOptions.logLevel,
|
|
355
|
+
onwarn: (warning) => {
|
|
356
|
+
if (warning.code === "CIRCULAR_DEPENDENCY") {
|
|
357
|
+
if (warning.ids?.[0]?.includes("node_modules")) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
this.logger.warn(`Circular dependency found:
|
|
361
|
+
${warning.message.replace("Circular dependency: ", "")}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
dir: bundleLocation,
|
|
367
|
+
manualChunks: {
|
|
368
|
+
mastra: ["#mastra"]
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
await bundler.write();
|
|
373
|
+
const toolsInputOptions = Array.from(Object.keys(inputOptions.input || {})).filter((key) => key.startsWith("tools/")).map((key) => `./${key}.mjs`);
|
|
374
|
+
await promises.writeFile(path.join(bundleLocation, "tools.mjs"), `export const tools = ${JSON.stringify(toolsInputOptions)};`);
|
|
375
|
+
this.logger.info("Bundling Mastra done");
|
|
376
|
+
this.logger.info("Copying public files");
|
|
377
|
+
await this.copyPublic(path.dirname(mastraEntryFile), outputDirectory);
|
|
378
|
+
this.logger.info("Done copying public files");
|
|
379
|
+
this.logger.info("Installing dependencies");
|
|
380
|
+
await this.installDependencies(outputDirectory);
|
|
381
|
+
this.logger.info("Done installing dependencies");
|
|
382
|
+
} catch (error$1) {
|
|
383
|
+
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
384
|
+
throw new error.MastraError(
|
|
385
|
+
{
|
|
386
|
+
id: "DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED",
|
|
387
|
+
text: `Failed during bundler bundle stage: ${message}`,
|
|
388
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
389
|
+
category: error.ErrorCategory.SYSTEM
|
|
390
|
+
},
|
|
391
|
+
error$1
|
|
392
|
+
);
|
|
393
|
+
}
|
|
326
394
|
}
|
|
327
395
|
async lint(_entryFile, _outputDirectory, toolsPaths) {
|
|
328
396
|
const toolsInputOptions = await this.getToolsInputOptions(toolsPaths);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkF4JNMQTU_cjs = require('./chunk-F4JNMQTU.cjs');
|
|
4
4
|
var chunkIMGVLBV7_cjs = require('./chunk-IMGVLBV7.cjs');
|
|
5
5
|
var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
|
|
6
6
|
var rollup = require('rollup');
|
|
@@ -121,7 +121,7 @@ async function getInputOptions2(entryFile, platform, env) {
|
|
|
121
121
|
// @ts-ignore
|
|
122
122
|
(plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
|
|
123
123
|
);
|
|
124
|
-
inputOptions.plugins.push(
|
|
124
|
+
inputOptions.plugins.push(chunkF4JNMQTU_cjs.aliasHono());
|
|
125
125
|
inputOptions.plugins.push(nodeModulesExtensionResolver());
|
|
126
126
|
}
|
|
127
127
|
return inputOptions;
|
|
@@ -141,7 +141,7 @@ async function createWatcher(inputOptions, outputOptions) {
|
|
|
141
141
|
|
|
142
142
|
// src/build/babel/remove-all-options-server.ts
|
|
143
143
|
function removeAllOptionsExceptServer(result) {
|
|
144
|
-
return
|
|
144
|
+
return chunkF4JNMQTU_cjs.removeAllOptionsFromMastraExcept(result, "server");
|
|
145
145
|
}
|
|
146
146
|
function getServerOptionsBundler(entryFile, result) {
|
|
147
147
|
return rollup.rollup({
|
|
@@ -204,7 +204,7 @@ function getServerOptionsBundler(entryFile, result) {
|
|
|
204
204
|
if (id !== entryFile) {
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
return
|
|
207
|
+
return chunkF4JNMQTU_cjs.recursiveRemoveNonReferencedNodes(code);
|
|
208
208
|
}
|
|
209
209
|
},
|
|
210
210
|
// let esbuild remove all unused imports
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkQGO33MM3_cjs = require('./chunk-QGO33MM3.cjs');
|
|
4
|
+
var chunkF4JNMQTU_cjs = require('./chunk-F4JNMQTU.cjs');
|
|
5
5
|
var chunk7ICGDVC3_cjs = require('./chunk-7ICGDVC3.cjs');
|
|
6
6
|
var babel = require('@babel/core');
|
|
7
7
|
var rollup = require('rollup');
|
|
@@ -33,7 +33,7 @@ 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
|
|
36
|
+
var Deployer = class extends chunkQGO33MM3_cjs.Bundler {
|
|
37
37
|
deps = new chunk7ICGDVC3_cjs.DepsService();
|
|
38
38
|
constructor(args) {
|
|
39
39
|
super(args.name, "DEPLOYER");
|
|
@@ -148,7 +148,7 @@ function getDeployerBundler(entryFile, result) {
|
|
|
148
148
|
if (id !== entryFile) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
return
|
|
151
|
+
return chunkF4JNMQTU_cjs.recursiveRemoveNonReferencedNodes(code);
|
|
152
152
|
}
|
|
153
153
|
},
|
|
154
154
|
// let esbuild remove all unused imports
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bundler } from './chunk-
|
|
2
|
-
import { recursiveRemoveNonReferencedNodes } from './chunk-
|
|
1
|
+
import { Bundler } from './chunk-72MENR23.js';
|
|
2
|
+
import { recursiveRemoveNonReferencedNodes } from './chunk-J2V6UIZO.js';
|
|
3
3
|
import { DepsService, FileService } from './chunk-4VKGIENI.js';
|
|
4
4
|
export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-4VKGIENI.js';
|
|
5
5
|
import * as babel from '@babel/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "0.10.6-alpha.
|
|
3
|
+
"version": "0.10.6-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"rollup-plugin-node-externals": "^8.0.0",
|
|
109
109
|
"typescript-paths": "^1.5.1",
|
|
110
110
|
"zod": "^3.25.57",
|
|
111
|
-
"@mastra/server": "^0.10.6-alpha.
|
|
111
|
+
"@mastra/server": "^0.10.6-alpha.5"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@hono/node-server": "^1.14.4",
|
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
"typescript": "^5.8.3",
|
|
129
129
|
"vitest": "^2.1.9",
|
|
130
130
|
"@internal/lint": "0.0.12",
|
|
131
|
-
"@mastra/
|
|
132
|
-
"@mastra/
|
|
131
|
+
"@mastra/core": "0.10.6-alpha.5",
|
|
132
|
+
"@mastra/mcp": "^0.10.4-alpha.1"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
135
135
|
"@mastra/core": "^0.10.2-alpha.0"
|