@mastra/deployer 0.2.3 → 0.2.4-alpha.0
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 +7 -0
- package/dist/_tsup-dts-rollup.d.ts +7 -0
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/index.cjs +11 -11
- package/dist/build/index.js +3 -3
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-IGPSPQAD.js → chunk-7J2ZTGHM.js} +2 -2
- package/dist/{chunk-T23IXDLE.js → chunk-ARY7G5XC.js} +71 -19
- package/dist/{chunk-FVHOV5SC.cjs → chunk-AXUXJ2OU.cjs} +3 -3
- package/dist/{chunk-XZSN3YN6.cjs → chunk-HBJIG6EL.cjs} +7 -7
- package/dist/{chunk-PRZC7CEM.cjs → chunk-KFOGAPGX.cjs} +94 -4
- package/dist/{chunk-KNO7RCEZ.cjs → chunk-QVHMDKNM.cjs} +70 -18
- package/dist/{chunk-UKRVXD63.js → chunk-YE3YSKC6.js} +1 -1
- package/dist/{chunk-7XQJJPRM.js → chunk-ZAXXMFXX.js} +93 -4
- package/dist/index.cjs +25 -10
- package/dist/index.js +20 -5
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.js +2 -2
- package/dist/validator/custom-resolver.cjs +24 -5
- package/dist/validator/custom-resolver.js +24 -5
- package/package.json +2 -2
|
@@ -335,6 +335,11 @@ export declare type PluginOptions = Omit<RegisterOptions, 'loggerID'>;
|
|
|
335
335
|
|
|
336
336
|
export declare function queryVectors(c: Context): Promise<Response>;
|
|
337
337
|
|
|
338
|
+
export declare function recursiveRemoveNonReferencedNodes(code: string): Promise<{
|
|
339
|
+
code: string;
|
|
340
|
+
map: any;
|
|
341
|
+
}>;
|
|
342
|
+
|
|
338
343
|
export declare function removeAllExceptDeployer(): babel_2.PluginObj;
|
|
339
344
|
|
|
340
345
|
export declare function removeAllExceptTelemetryConfig(result: {
|
|
@@ -345,6 +350,8 @@ export declare function removeDeployer(): babel_2.PluginObj;
|
|
|
345
350
|
|
|
346
351
|
export declare function removeDeployer_alias_1(mastraEntry: string): Plugin;
|
|
347
352
|
|
|
353
|
+
export declare function removeNonReferencedNodes(): babel_2.PluginObj;
|
|
354
|
+
|
|
348
355
|
export declare function resolve(specifier: string, context: ResolveHookContext, nextResolve: (specifier: string, context: ResolveHookContext) => Promise<{
|
|
349
356
|
url: string;
|
|
350
357
|
}>): Promise<{
|
|
@@ -335,6 +335,11 @@ export declare type PluginOptions = Omit<RegisterOptions, 'loggerID'>;
|
|
|
335
335
|
|
|
336
336
|
export declare function queryVectors(c: Context): Promise<Response>;
|
|
337
337
|
|
|
338
|
+
export declare function recursiveRemoveNonReferencedNodes(code: string): Promise<{
|
|
339
|
+
code: string;
|
|
340
|
+
map: any;
|
|
341
|
+
}>;
|
|
342
|
+
|
|
338
343
|
export declare function removeAllExceptDeployer(): babel_2.PluginObj;
|
|
339
344
|
|
|
340
345
|
export declare function removeAllExceptTelemetryConfig(result: {
|
|
@@ -345,6 +350,8 @@ export declare function removeDeployer(): babel_2.PluginObj;
|
|
|
345
350
|
|
|
346
351
|
export declare function removeDeployer_alias_1(mastraEntry: string): Plugin;
|
|
347
352
|
|
|
353
|
+
export declare function removeNonReferencedNodes(): babel_2.PluginObj;
|
|
354
|
+
|
|
348
355
|
export declare function resolve(specifier: string, context: ResolveHookContext, nextResolve: (specifier: string, context: ResolveHookContext) => Promise<{
|
|
349
356
|
url: string;
|
|
350
357
|
}>): Promise<{
|
package/dist/build/analyze.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQVHMDKNM_cjs = require('../chunk-QVHMDKNM.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 chunkQVHMDKNM_cjs.analyzeBundle; }
|
|
10
10
|
});
|
package/dist/build/analyze.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { analyzeBundle } from '../chunk-
|
|
1
|
+
export { analyzeBundle } from '../chunk-ARY7G5XC.js';
|
package/dist/build/index.cjs
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkAXUXJ2OU_cjs = require('../chunk-AXUXJ2OU.cjs');
|
|
4
|
+
var chunkKFOGAPGX_cjs = require('../chunk-KFOGAPGX.cjs');
|
|
5
|
+
var chunkQVHMDKNM_cjs = require('../chunk-QVHMDKNM.cjs');
|
|
6
6
|
var chunkOT6UKL2S_cjs = require('../chunk-OT6UKL2S.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "FileService", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkAXUXJ2OU_cjs.FileService; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "createWatcher", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkAXUXJ2OU_cjs.createWatcher; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "getBundler", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkAXUXJ2OU_cjs.getBundler; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "getWatcher", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkAXUXJ2OU_cjs.getWatcher; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "getWatcherInputOptions", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkAXUXJ2OU_cjs.getInputOptions; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "Deps", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkKFOGAPGX_cjs.Deps; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "writeTelemetryConfig", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkKFOGAPGX_cjs.writeTelemetryConfig; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "analyzeBundle", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkQVHMDKNM_cjs.analyzeBundle; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "createBundler", {
|
|
43
43
|
enumerable: true,
|
package/dist/build/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FileService, createWatcher, getBundler, getWatcher, getInputOptions as getWatcherInputOptions } from '../chunk-
|
|
2
|
-
export { Deps, writeTelemetryConfig } from '../chunk-
|
|
3
|
-
export { analyzeBundle } from '../chunk-
|
|
1
|
+
export { FileService, createWatcher, getBundler, getWatcher, getInputOptions as getWatcherInputOptions } from '../chunk-YE3YSKC6.js';
|
|
2
|
+
export { Deps, writeTelemetryConfig } from '../chunk-ZAXXMFXX.js';
|
|
3
|
+
export { analyzeBundle } from '../chunk-ARY7G5XC.js';
|
|
4
4
|
export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-XEFBJH3T.js';
|
package/dist/bundler/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkHBJIG6EL_cjs = require('../chunk-HBJIG6EL.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 chunkHBJIG6EL_cjs.Bundler; }
|
|
10
10
|
});
|
package/dist/bundler/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Bundler } from '../chunk-
|
|
1
|
+
export { Bundler } from '../chunk-7J2ZTGHM.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Deps, writeTelemetryConfig } from './chunk-
|
|
2
|
-
import { analyzeBundle } from './chunk-
|
|
1
|
+
import { Deps, writeTelemetryConfig } from './chunk-ZAXXMFXX.js';
|
|
2
|
+
import { analyzeBundle } from './chunk-ARY7G5XC.js';
|
|
3
3
|
import { createBundler, getInputOptions } from './chunk-XEFBJH3T.js';
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import { writeFile, stat } from 'node:fs/promises';
|
|
@@ -8,8 +8,9 @@ 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';
|
|
11
|
+
import { join, dirname } from 'node:path';
|
|
12
12
|
import { spawn as spawn$1 } from 'node:child_process';
|
|
13
|
+
import { writeFile } from 'node:fs/promises';
|
|
13
14
|
|
|
14
15
|
function isNodeBuiltin(dep) {
|
|
15
16
|
const [pkg] = dep.split("/");
|
|
@@ -50,17 +51,40 @@ function spawn(command, args = [], options = {}) {
|
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
function validate(file) {
|
|
53
|
-
return spawn(
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
return spawn(
|
|
55
|
+
"node",
|
|
56
|
+
[
|
|
57
|
+
"--import",
|
|
58
|
+
import.meta.resolve("@mastra/deployer/loader"),
|
|
59
|
+
"--input-type=module",
|
|
60
|
+
"-e",
|
|
61
|
+
`import('file://${file.replaceAll("\\", "/")}')`
|
|
62
|
+
],
|
|
63
|
+
{
|
|
64
|
+
cwd: dirname(file)
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
var globalExternals = ["pino", "pino-pretty", "@libsql/client", "pg", "libsql", "jsdom", "sqlite3"];
|
|
69
|
+
function findExternalImporter(module, external, allOutputs) {
|
|
70
|
+
const capturedFiles = /* @__PURE__ */ new Set();
|
|
71
|
+
for (const id of module.imports) {
|
|
72
|
+
if (id === external) {
|
|
73
|
+
return module;
|
|
74
|
+
} else {
|
|
75
|
+
if (id.endsWith(".mjs")) {
|
|
76
|
+
capturedFiles.add(id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const file of capturedFiles) {
|
|
81
|
+
const nextModule = allOutputs.find((o) => o.fileName === file);
|
|
82
|
+
if (nextModule) {
|
|
83
|
+
return findExternalImporter(nextModule, external, allOutputs);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
60
87
|
}
|
|
61
|
-
|
|
62
|
-
// src/build/analyze.ts
|
|
63
|
-
var globalExternals = ["pino", "pino-pretty", "@libsql/client"];
|
|
64
88
|
async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
|
|
65
89
|
logger.info("Analyzing dependencies...");
|
|
66
90
|
let virtualPlugin = null;
|
|
@@ -163,9 +187,8 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
|
|
|
163
187
|
),
|
|
164
188
|
// this dependency breaks the build, so we need to exclude it
|
|
165
189
|
// TODO actually fix this so we don't need to exclude it
|
|
166
|
-
external:
|
|
190
|
+
external: globalExternals,
|
|
167
191
|
treeshake: "smallest",
|
|
168
|
-
preserveSymlinks: true,
|
|
169
192
|
plugins: [
|
|
170
193
|
virtual(
|
|
171
194
|
Array.from(virtualDependencies.entries()).reduce(
|
|
@@ -195,18 +218,43 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
|
|
|
195
218
|
format: "esm",
|
|
196
219
|
dir: outputDir,
|
|
197
220
|
entryFileNames: "[name].mjs",
|
|
198
|
-
chunkFileNames: "[name].mjs"
|
|
221
|
+
chunkFileNames: "[name].mjs",
|
|
222
|
+
hoistTransitiveImports: false
|
|
199
223
|
});
|
|
224
|
+
const moduleResolveMap = {};
|
|
225
|
+
const filteredChunks = output.filter((o) => o.type === "chunk");
|
|
226
|
+
for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
|
|
227
|
+
for (const external of globalExternals) {
|
|
228
|
+
const importer = findExternalImporter(o, external, filteredChunks);
|
|
229
|
+
if (importer) {
|
|
230
|
+
const fullPath = join(outputDir, importer.fileName);
|
|
231
|
+
moduleResolveMap[fullPath] = moduleResolveMap[fullPath] || {};
|
|
232
|
+
if (importer.moduleIds.length > 1) {
|
|
233
|
+
moduleResolveMap[fullPath][external] = importer.moduleIds.slice(-2, -1)[0];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
await writeFile(join(outputDir, "module-resolve-map.json"), JSON.stringify(moduleResolveMap, null, 2));
|
|
200
239
|
await bundler.close();
|
|
201
|
-
return { output, reverseVirtualReferenceMap };
|
|
240
|
+
return { output, reverseVirtualReferenceMap, usedExternals: moduleResolveMap };
|
|
202
241
|
}
|
|
203
|
-
async function validateOutput(
|
|
242
|
+
async function validateOutput({
|
|
243
|
+
output,
|
|
244
|
+
reverseVirtualReferenceMap,
|
|
245
|
+
usedExternals,
|
|
246
|
+
outputDir
|
|
247
|
+
}, logger) {
|
|
204
248
|
const result = {
|
|
205
249
|
invalidChunks: /* @__PURE__ */ new Set(),
|
|
206
250
|
dependencies: /* @__PURE__ */ new Map(),
|
|
207
251
|
externalDependencies: /* @__PURE__ */ new Set()
|
|
208
252
|
};
|
|
209
|
-
|
|
253
|
+
for (const deps of Object.values(usedExternals)) {
|
|
254
|
+
for (const dep of Object.keys(deps)) {
|
|
255
|
+
result.externalDependencies.add(dep);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
210
258
|
for (const file of output) {
|
|
211
259
|
if (file.type === "asset") {
|
|
212
260
|
continue;
|
|
@@ -231,8 +279,12 @@ async function validateOutput(output, reverseVirtualReferenceMap, outputDir, log
|
|
|
231
279
|
async function analyzeBundle(entry, mastraEntry, outputDir, platform, logger) {
|
|
232
280
|
const isVirtualFile = entry.includes("\n") || !existsSync(entry);
|
|
233
281
|
const depsToOptimize = await analyze(entry, mastraEntry, isVirtualFile, platform, logger);
|
|
234
|
-
const { output, reverseVirtualReferenceMap } = await bundleExternals(
|
|
235
|
-
|
|
282
|
+
const { output, reverseVirtualReferenceMap, usedExternals } = await bundleExternals(
|
|
283
|
+
depsToOptimize,
|
|
284
|
+
outputDir,
|
|
285
|
+
logger
|
|
286
|
+
);
|
|
287
|
+
const result = await validateOutput({ output, reverseVirtualReferenceMap, usedExternals, outputDir }, logger);
|
|
236
288
|
return result;
|
|
237
289
|
}
|
|
238
290
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQVHMDKNM_cjs = require('./chunk-QVHMDKNM.cjs');
|
|
4
4
|
var chunkOT6UKL2S_cjs = require('./chunk-OT6UKL2S.cjs');
|
|
5
5
|
var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
|
|
6
6
|
var alias = require('@rollup/plugin-alias');
|
|
@@ -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-
|
|
119
|
+
const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-AXUXJ2OU.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");
|
|
@@ -262,7 +262,7 @@ async function getInputOptions2(entryFile, platform) {
|
|
|
262
262
|
// @ts-ignore
|
|
263
263
|
(plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
|
|
264
264
|
);
|
|
265
|
-
inputOptions.plugins.push(
|
|
265
|
+
inputOptions.plugins.push(chunkQVHMDKNM_cjs.aliasHono());
|
|
266
266
|
}
|
|
267
267
|
return inputOptions;
|
|
268
268
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkKFOGAPGX_cjs = require('./chunk-KFOGAPGX.cjs');
|
|
4
|
+
var chunkQVHMDKNM_cjs = require('./chunk-QVHMDKNM.cjs');
|
|
5
5
|
var chunkOT6UKL2S_cjs = require('./chunk-OT6UKL2S.cjs');
|
|
6
6
|
var fs = require('fs');
|
|
7
7
|
var promises = require('fs/promises');
|
|
@@ -31,7 +31,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
31
31
|
}
|
|
32
32
|
async writeInstrumentationFile(outputDirectory) {
|
|
33
33
|
const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
34
|
-
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-
|
|
34
|
+
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-HBJIG6EL.cjs', document.baseURI).href))));
|
|
35
35
|
await esm.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
|
|
36
36
|
}
|
|
37
37
|
async writePackageJson(outputDirectory, dependencies) {
|
|
@@ -73,10 +73,10 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
73
73
|
return chunkOT6UKL2S_cjs.createBundler(inputOptions, outputOptions);
|
|
74
74
|
}
|
|
75
75
|
async analyze(entry, mastraFile, outputDirectory) {
|
|
76
|
-
return await
|
|
76
|
+
return await chunkQVHMDKNM_cjs.analyzeBundle(entry, mastraFile, path.join(outputDirectory, this.analyzeOutputDir), "node", this.logger);
|
|
77
77
|
}
|
|
78
78
|
async installDependencies(outputDirectory, rootDir = process.cwd()) {
|
|
79
|
-
const deps = new
|
|
79
|
+
const deps = new chunkKFOGAPGX_cjs.Deps(rootDir);
|
|
80
80
|
deps.__setLogger(this.logger);
|
|
81
81
|
await deps.install({ dir: path.join(outputDirectory, this.outputDir) });
|
|
82
82
|
}
|
|
@@ -92,14 +92,14 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
92
92
|
async _bundle(serverFile, mastraEntryFile, outputDirectory, bundleLocation = path.join(outputDirectory, this.outputDir)) {
|
|
93
93
|
this.logger.info("Start bundling Mastra");
|
|
94
94
|
const isVirtual = serverFile.includes("\n") || fs.existsSync(serverFile);
|
|
95
|
-
const analyzedBundleInfo = await
|
|
95
|
+
const analyzedBundleInfo = await chunkQVHMDKNM_cjs.analyzeBundle(
|
|
96
96
|
serverFile,
|
|
97
97
|
mastraEntryFile,
|
|
98
98
|
path.join(outputDirectory, this.analyzeOutputDir),
|
|
99
99
|
"node",
|
|
100
100
|
this.logger
|
|
101
101
|
);
|
|
102
|
-
await
|
|
102
|
+
await chunkKFOGAPGX_cjs.writeTelemetryConfig(mastraEntryFile, path.join(outputDirectory, this.outputDir));
|
|
103
103
|
const dependenciesToInstall = /* @__PURE__ */ new Map();
|
|
104
104
|
for (const dep of analyzedBundleInfo.externalDependencies) {
|
|
105
105
|
try {
|
|
@@ -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-
|
|
202
|
+
const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KFOGAPGX.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);
|
|
@@ -234,10 +234,11 @@ function removeAllExceptTelemetryConfig(result) {
|
|
|
234
234
|
if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
let mastraArgs = t.objectExpression([]);
|
|
238
|
+
if (t.isObjectExpression(path2.node.arguments[0])) {
|
|
239
|
+
mastraArgs = path2.node.arguments[0];
|
|
239
240
|
}
|
|
240
|
-
let telemetry =
|
|
241
|
+
let telemetry = mastraArgs.properties.find(
|
|
241
242
|
// @ts-ignore
|
|
242
243
|
(prop) => prop.key.name === "telemetry"
|
|
243
244
|
);
|
|
@@ -267,6 +268,79 @@ function removeAllExceptTelemetryConfig(result) {
|
|
|
267
268
|
}
|
|
268
269
|
};
|
|
269
270
|
}
|
|
271
|
+
function removeNonReferencedNodes() {
|
|
272
|
+
const t = babel__namespace.default.types;
|
|
273
|
+
return {
|
|
274
|
+
name: "remove-non-referenced-nodes",
|
|
275
|
+
visitor: {
|
|
276
|
+
Program(path2) {
|
|
277
|
+
const scope = path2.scope;
|
|
278
|
+
const currentBody = path2.get("body");
|
|
279
|
+
const filteredBody = currentBody.filter((childPath) => {
|
|
280
|
+
if (childPath.isExportDeclaration()) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
if (childPath.isVariableDeclaration()) {
|
|
284
|
+
return childPath.node.declarations.some((decl) => {
|
|
285
|
+
if (!t.isIdentifier(decl.id)) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
const name = decl.id.name;
|
|
289
|
+
const binding = scope.getBinding(name);
|
|
290
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
|
|
294
|
+
if (!t.isIdentifier(childPath.node.id)) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
const name = childPath.node.id.name;
|
|
298
|
+
const binding = scope.getBinding(name);
|
|
299
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
300
|
+
}
|
|
301
|
+
if (childPath.isImportDeclaration()) {
|
|
302
|
+
return childPath.node.specifiers.some((specifier) => {
|
|
303
|
+
const importedName = specifier.local.name;
|
|
304
|
+
const binding = scope.getBinding(importedName);
|
|
305
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return false;
|
|
309
|
+
});
|
|
310
|
+
path2.set(
|
|
311
|
+
"body",
|
|
312
|
+
filteredBody.map((p) => p.node)
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function recursiveRemoveNonReferencedNodes(code) {
|
|
319
|
+
return new Promise(async (resolve, reject) => {
|
|
320
|
+
babel__namespace.transform(
|
|
321
|
+
code,
|
|
322
|
+
{
|
|
323
|
+
babelrc: false,
|
|
324
|
+
configFile: false,
|
|
325
|
+
plugins: [removeNonReferencedNodes()]
|
|
326
|
+
},
|
|
327
|
+
(err, result) => {
|
|
328
|
+
if (err) {
|
|
329
|
+
return reject(err);
|
|
330
|
+
}
|
|
331
|
+
if (result && result.code !== code) {
|
|
332
|
+
return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
|
|
333
|
+
}
|
|
334
|
+
resolve({
|
|
335
|
+
code: result.code,
|
|
336
|
+
map: result.map
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// src/build/telemetry.ts
|
|
270
344
|
function getTelemetryBundler(entryFile, result) {
|
|
271
345
|
return rollup.rollup({
|
|
272
346
|
logLevel: "silent",
|
|
@@ -316,6 +390,21 @@ function getTelemetryBundler(entryFile, result) {
|
|
|
316
390
|
}
|
|
317
391
|
},
|
|
318
392
|
// let esbuild remove all unused imports
|
|
393
|
+
esbuild__default.default({
|
|
394
|
+
target: "node20",
|
|
395
|
+
platform: "node",
|
|
396
|
+
minify: false
|
|
397
|
+
}),
|
|
398
|
+
{
|
|
399
|
+
name: "cleanup",
|
|
400
|
+
transform(code, id) {
|
|
401
|
+
if (id !== entryFile) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
return recursiveRemoveNonReferencedNodes(code);
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
// let esbuild remove all unused imports
|
|
319
408
|
esbuild__default.default({
|
|
320
409
|
target: "node20",
|
|
321
410
|
platform: "node",
|
|
@@ -340,4 +429,5 @@ async function writeTelemetryConfig(entryFile, outputDir) {
|
|
|
340
429
|
exports.Deps = Deps;
|
|
341
430
|
exports.createChildProcessLogger = createChildProcessLogger;
|
|
342
431
|
exports.createPinoStream = createPinoStream;
|
|
432
|
+
exports.recursiveRemoveNonReferencedNodes = recursiveRemoveNonReferencedNodes;
|
|
343
433
|
exports.writeTelemetryConfig = writeTelemetryConfig;
|
|
@@ -12,6 +12,7 @@ var esbuild = require('rollup-plugin-esbuild');
|
|
|
12
12
|
var module$1 = require('module');
|
|
13
13
|
var path = require('path');
|
|
14
14
|
var child_process = require('child_process');
|
|
15
|
+
var promises = require('fs/promises');
|
|
15
16
|
|
|
16
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
|
|
@@ -60,17 +61,40 @@ function spawn(command, args = [], options = {}) {
|
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
function validate(file) {
|
|
63
|
-
return spawn(
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
return spawn(
|
|
65
|
+
"node",
|
|
66
|
+
[
|
|
67
|
+
"--import",
|
|
68
|
+
undefined("@mastra/deployer/loader"),
|
|
69
|
+
"--input-type=module",
|
|
70
|
+
"-e",
|
|
71
|
+
`import('file://${file.replaceAll("\\", "/")}')`
|
|
72
|
+
],
|
|
73
|
+
{
|
|
74
|
+
cwd: path.dirname(file)
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
var globalExternals = ["pino", "pino-pretty", "@libsql/client", "pg", "libsql", "jsdom", "sqlite3"];
|
|
79
|
+
function findExternalImporter(module, external, allOutputs) {
|
|
80
|
+
const capturedFiles = /* @__PURE__ */ new Set();
|
|
81
|
+
for (const id of module.imports) {
|
|
82
|
+
if (id === external) {
|
|
83
|
+
return module;
|
|
84
|
+
} else {
|
|
85
|
+
if (id.endsWith(".mjs")) {
|
|
86
|
+
capturedFiles.add(id);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const file of capturedFiles) {
|
|
91
|
+
const nextModule = allOutputs.find((o) => o.fileName === file);
|
|
92
|
+
if (nextModule) {
|
|
93
|
+
return findExternalImporter(nextModule, external, allOutputs);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
70
97
|
}
|
|
71
|
-
|
|
72
|
-
// src/build/analyze.ts
|
|
73
|
-
var globalExternals = ["pino", "pino-pretty", "@libsql/client"];
|
|
74
98
|
async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
|
|
75
99
|
logger.info("Analyzing dependencies...");
|
|
76
100
|
let virtualPlugin = null;
|
|
@@ -173,9 +197,8 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
|
|
|
173
197
|
),
|
|
174
198
|
// this dependency breaks the build, so we need to exclude it
|
|
175
199
|
// TODO actually fix this so we don't need to exclude it
|
|
176
|
-
external:
|
|
200
|
+
external: globalExternals,
|
|
177
201
|
treeshake: "smallest",
|
|
178
|
-
preserveSymlinks: true,
|
|
179
202
|
plugins: [
|
|
180
203
|
virtual__default.default(
|
|
181
204
|
Array.from(virtualDependencies.entries()).reduce(
|
|
@@ -205,18 +228,43 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
|
|
|
205
228
|
format: "esm",
|
|
206
229
|
dir: outputDir,
|
|
207
230
|
entryFileNames: "[name].mjs",
|
|
208
|
-
chunkFileNames: "[name].mjs"
|
|
231
|
+
chunkFileNames: "[name].mjs",
|
|
232
|
+
hoistTransitiveImports: false
|
|
209
233
|
});
|
|
234
|
+
const moduleResolveMap = {};
|
|
235
|
+
const filteredChunks = output.filter((o) => o.type === "chunk");
|
|
236
|
+
for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
|
|
237
|
+
for (const external of globalExternals) {
|
|
238
|
+
const importer = findExternalImporter(o, external, filteredChunks);
|
|
239
|
+
if (importer) {
|
|
240
|
+
const fullPath = path.join(outputDir, importer.fileName);
|
|
241
|
+
moduleResolveMap[fullPath] = moduleResolveMap[fullPath] || {};
|
|
242
|
+
if (importer.moduleIds.length > 1) {
|
|
243
|
+
moduleResolveMap[fullPath][external] = importer.moduleIds.slice(-2, -1)[0];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
await promises.writeFile(path.join(outputDir, "module-resolve-map.json"), JSON.stringify(moduleResolveMap, null, 2));
|
|
210
249
|
await bundler.close();
|
|
211
|
-
return { output, reverseVirtualReferenceMap };
|
|
250
|
+
return { output, reverseVirtualReferenceMap, usedExternals: moduleResolveMap };
|
|
212
251
|
}
|
|
213
|
-
async function validateOutput(
|
|
252
|
+
async function validateOutput({
|
|
253
|
+
output,
|
|
254
|
+
reverseVirtualReferenceMap,
|
|
255
|
+
usedExternals,
|
|
256
|
+
outputDir
|
|
257
|
+
}, logger) {
|
|
214
258
|
const result = {
|
|
215
259
|
invalidChunks: /* @__PURE__ */ new Set(),
|
|
216
260
|
dependencies: /* @__PURE__ */ new Map(),
|
|
217
261
|
externalDependencies: /* @__PURE__ */ new Set()
|
|
218
262
|
};
|
|
219
|
-
|
|
263
|
+
for (const deps of Object.values(usedExternals)) {
|
|
264
|
+
for (const dep of Object.keys(deps)) {
|
|
265
|
+
result.externalDependencies.add(dep);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
220
268
|
for (const file of output) {
|
|
221
269
|
if (file.type === "asset") {
|
|
222
270
|
continue;
|
|
@@ -241,8 +289,12 @@ async function validateOutput(output, reverseVirtualReferenceMap, outputDir, log
|
|
|
241
289
|
async function analyzeBundle(entry, mastraEntry, outputDir, platform, logger) {
|
|
242
290
|
const isVirtualFile = entry.includes("\n") || !fs.existsSync(entry);
|
|
243
291
|
const depsToOptimize = await analyze(entry, mastraEntry, isVirtualFile, platform, logger);
|
|
244
|
-
const { output, reverseVirtualReferenceMap } = await bundleExternals(
|
|
245
|
-
|
|
292
|
+
const { output, reverseVirtualReferenceMap, usedExternals } = await bundleExternals(
|
|
293
|
+
depsToOptimize,
|
|
294
|
+
outputDir,
|
|
295
|
+
logger
|
|
296
|
+
);
|
|
297
|
+
const result = await validateOutput({ output, reverseVirtualReferenceMap, usedExternals, outputDir }, logger);
|
|
246
298
|
return result;
|
|
247
299
|
}
|
|
248
300
|
|
|
@@ -204,10 +204,11 @@ function removeAllExceptTelemetryConfig(result) {
|
|
|
204
204
|
if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
let mastraArgs = t.objectExpression([]);
|
|
208
|
+
if (t.isObjectExpression(path2.node.arguments[0])) {
|
|
209
|
+
mastraArgs = path2.node.arguments[0];
|
|
209
210
|
}
|
|
210
|
-
let telemetry =
|
|
211
|
+
let telemetry = mastraArgs.properties.find(
|
|
211
212
|
// @ts-ignore
|
|
212
213
|
(prop) => prop.key.name === "telemetry"
|
|
213
214
|
);
|
|
@@ -237,6 +238,79 @@ function removeAllExceptTelemetryConfig(result) {
|
|
|
237
238
|
}
|
|
238
239
|
};
|
|
239
240
|
}
|
|
241
|
+
function removeNonReferencedNodes() {
|
|
242
|
+
const t = babel__default.types;
|
|
243
|
+
return {
|
|
244
|
+
name: "remove-non-referenced-nodes",
|
|
245
|
+
visitor: {
|
|
246
|
+
Program(path2) {
|
|
247
|
+
const scope = path2.scope;
|
|
248
|
+
const currentBody = path2.get("body");
|
|
249
|
+
const filteredBody = currentBody.filter((childPath) => {
|
|
250
|
+
if (childPath.isExportDeclaration()) {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
if (childPath.isVariableDeclaration()) {
|
|
254
|
+
return childPath.node.declarations.some((decl) => {
|
|
255
|
+
if (!t.isIdentifier(decl.id)) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
const name = decl.id.name;
|
|
259
|
+
const binding = scope.getBinding(name);
|
|
260
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
|
|
264
|
+
if (!t.isIdentifier(childPath.node.id)) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
const name = childPath.node.id.name;
|
|
268
|
+
const binding = scope.getBinding(name);
|
|
269
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
270
|
+
}
|
|
271
|
+
if (childPath.isImportDeclaration()) {
|
|
272
|
+
return childPath.node.specifiers.some((specifier) => {
|
|
273
|
+
const importedName = specifier.local.name;
|
|
274
|
+
const binding = scope.getBinding(importedName);
|
|
275
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
});
|
|
280
|
+
path2.set(
|
|
281
|
+
"body",
|
|
282
|
+
filteredBody.map((p) => p.node)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function recursiveRemoveNonReferencedNodes(code) {
|
|
289
|
+
return new Promise(async (resolve, reject) => {
|
|
290
|
+
babel.transform(
|
|
291
|
+
code,
|
|
292
|
+
{
|
|
293
|
+
babelrc: false,
|
|
294
|
+
configFile: false,
|
|
295
|
+
plugins: [removeNonReferencedNodes()]
|
|
296
|
+
},
|
|
297
|
+
(err, result) => {
|
|
298
|
+
if (err) {
|
|
299
|
+
return reject(err);
|
|
300
|
+
}
|
|
301
|
+
if (result && result.code !== code) {
|
|
302
|
+
return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
|
|
303
|
+
}
|
|
304
|
+
resolve({
|
|
305
|
+
code: result.code,
|
|
306
|
+
map: result.map
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/build/telemetry.ts
|
|
240
314
|
function getTelemetryBundler(entryFile, result) {
|
|
241
315
|
return rollup({
|
|
242
316
|
logLevel: "silent",
|
|
@@ -286,6 +360,21 @@ function getTelemetryBundler(entryFile, result) {
|
|
|
286
360
|
}
|
|
287
361
|
},
|
|
288
362
|
// let esbuild remove all unused imports
|
|
363
|
+
esbuild({
|
|
364
|
+
target: "node20",
|
|
365
|
+
platform: "node",
|
|
366
|
+
minify: false
|
|
367
|
+
}),
|
|
368
|
+
{
|
|
369
|
+
name: "cleanup",
|
|
370
|
+
transform(code, id) {
|
|
371
|
+
if (id !== entryFile) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
return recursiveRemoveNonReferencedNodes(code);
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
// let esbuild remove all unused imports
|
|
289
378
|
esbuild({
|
|
290
379
|
target: "node20",
|
|
291
380
|
platform: "node",
|
|
@@ -307,4 +396,4 @@ async function writeTelemetryConfig(entryFile, outputDir) {
|
|
|
307
396
|
return result;
|
|
308
397
|
}
|
|
309
398
|
|
|
310
|
-
export { Deps, createChildProcessLogger, createPinoStream, writeTelemetryConfig };
|
|
399
|
+
export { Deps, createChildProcessLogger, createPinoStream, recursiveRemoveNonReferencedNodes, writeTelemetryConfig };
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkAXUXJ2OU_cjs = require('./chunk-AXUXJ2OU.cjs');
|
|
4
|
+
var chunkHBJIG6EL_cjs = require('./chunk-HBJIG6EL.cjs');
|
|
5
|
+
var chunkKFOGAPGX_cjs = require('./chunk-KFOGAPGX.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
|
|
37
|
-
deps = new
|
|
36
|
+
var Deployer = class extends chunkHBJIG6EL_cjs.Bundler {
|
|
37
|
+
deps = new chunkKFOGAPGX_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 chunkXZSN3YN6_cjs.Bundler {
|
|
|
42
42
|
getEnvFiles() {
|
|
43
43
|
const possibleFiles = [".env.production", ".env.local", ".env"];
|
|
44
44
|
try {
|
|
45
|
-
const fileService = new
|
|
45
|
+
const fileService = new chunkAXUXJ2OU_cjs.FileService();
|
|
46
46
|
const envFile = fileService.getFirstExistingFile(possibleFiles);
|
|
47
47
|
return Promise.resolve([envFile]);
|
|
48
48
|
} catch {
|
|
@@ -136,6 +136,21 @@ function getDeployerBundler(entryFile) {
|
|
|
136
136
|
}
|
|
137
137
|
},
|
|
138
138
|
// let esbuild remove all unused imports
|
|
139
|
+
esbuild__default.default({
|
|
140
|
+
target: "node20",
|
|
141
|
+
platform: "node",
|
|
142
|
+
minify: false
|
|
143
|
+
}),
|
|
144
|
+
{
|
|
145
|
+
name: "cleanup-nodes",
|
|
146
|
+
transform(code, id) {
|
|
147
|
+
if (id !== entryFile) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
return chunkKFOGAPGX_cjs.recursiveRemoveNonReferencedNodes(code);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
// let esbuild remove all unused imports
|
|
139
154
|
esbuild__default.default({
|
|
140
155
|
target: "node20",
|
|
141
156
|
platform: "node",
|
|
@@ -156,19 +171,19 @@ async function getDeployer(entryFile, outputDir) {
|
|
|
156
171
|
|
|
157
172
|
Object.defineProperty(exports, "FileService", {
|
|
158
173
|
enumerable: true,
|
|
159
|
-
get: function () { return
|
|
174
|
+
get: function () { return chunkAXUXJ2OU_cjs.FileService; }
|
|
160
175
|
});
|
|
161
176
|
Object.defineProperty(exports, "Deps", {
|
|
162
177
|
enumerable: true,
|
|
163
|
-
get: function () { return
|
|
178
|
+
get: function () { return chunkKFOGAPGX_cjs.Deps; }
|
|
164
179
|
});
|
|
165
180
|
Object.defineProperty(exports, "createChildProcessLogger", {
|
|
166
181
|
enumerable: true,
|
|
167
|
-
get: function () { return
|
|
182
|
+
get: function () { return chunkKFOGAPGX_cjs.createChildProcessLogger; }
|
|
168
183
|
});
|
|
169
184
|
Object.defineProperty(exports, "createPinoStream", {
|
|
170
185
|
enumerable: true,
|
|
171
|
-
get: function () { return
|
|
186
|
+
get: function () { return chunkKFOGAPGX_cjs.createPinoStream; }
|
|
172
187
|
});
|
|
173
188
|
exports.Deployer = Deployer;
|
|
174
189
|
exports.getDeployer = getDeployer;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FileService } from './chunk-
|
|
2
|
-
export { FileService } from './chunk-
|
|
3
|
-
import { Bundler } from './chunk-
|
|
4
|
-
import { Deps } from './chunk-
|
|
5
|
-
export { Deps, createChildProcessLogger, createPinoStream } from './chunk-
|
|
1
|
+
import { FileService } from './chunk-YE3YSKC6.js';
|
|
2
|
+
export { FileService } from './chunk-YE3YSKC6.js';
|
|
3
|
+
import { Bundler } from './chunk-7J2ZTGHM.js';
|
|
4
|
+
import { Deps, recursiveRemoveNonReferencedNodes } from './chunk-ZAXXMFXX.js';
|
|
5
|
+
export { Deps, createChildProcessLogger, createPinoStream } from './chunk-ZAXXMFXX.js';
|
|
6
6
|
import * as babel from '@babel/core';
|
|
7
7
|
import babel__default from '@babel/core';
|
|
8
8
|
import { rollup } from 'rollup';
|
|
@@ -113,6 +113,21 @@ function getDeployerBundler(entryFile) {
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
// let esbuild remove all unused imports
|
|
116
|
+
esbuild({
|
|
117
|
+
target: "node20",
|
|
118
|
+
platform: "node",
|
|
119
|
+
minify: false
|
|
120
|
+
}),
|
|
121
|
+
{
|
|
122
|
+
name: "cleanup-nodes",
|
|
123
|
+
transform(code, id) {
|
|
124
|
+
if (id !== entryFile) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
return recursiveRemoveNonReferencedNodes(code);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
// let esbuild remove all unused imports
|
|
116
131
|
esbuild({
|
|
117
132
|
target: "node20",
|
|
118
133
|
platform: "node",
|
package/dist/server/index.cjs
CHANGED
|
@@ -3723,7 +3723,7 @@ async function speakHandler(c2) {
|
|
|
3723
3723
|
const { input, options } = await c2.req.json();
|
|
3724
3724
|
await validateBody({ input });
|
|
3725
3725
|
const audioStream = await agent.voice.speak(input, options);
|
|
3726
|
-
c2.header("Content-Type", `audio/${options
|
|
3726
|
+
c2.header("Content-Type", `audio/${options?.filetype ?? "mp3"}`);
|
|
3727
3727
|
c2.header("Transfer-Encoding", "chunked");
|
|
3728
3728
|
return c2.body(audioStream);
|
|
3729
3729
|
} catch (error) {
|
|
@@ -4750,7 +4750,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
4750
4750
|
schema: {
|
|
4751
4751
|
type: "object",
|
|
4752
4752
|
properties: {
|
|
4753
|
-
|
|
4753
|
+
input: {
|
|
4754
4754
|
type: "string",
|
|
4755
4755
|
description: "Text to convert to speech"
|
|
4756
4756
|
},
|
package/dist/server/index.js
CHANGED
|
@@ -3717,7 +3717,7 @@ async function speakHandler(c2) {
|
|
|
3717
3717
|
const { input, options } = await c2.req.json();
|
|
3718
3718
|
await validateBody({ input });
|
|
3719
3719
|
const audioStream = await agent.voice.speak(input, options);
|
|
3720
|
-
c2.header("Content-Type", `audio/${options
|
|
3720
|
+
c2.header("Content-Type", `audio/${options?.filetype ?? "mp3"}`);
|
|
3721
3721
|
c2.header("Transfer-Encoding", "chunked");
|
|
3722
3722
|
return c2.body(audioStream);
|
|
3723
3723
|
} catch (error) {
|
|
@@ -4744,7 +4744,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
4744
4744
|
schema: {
|
|
4745
4745
|
type: "object",
|
|
4746
4746
|
properties: {
|
|
4747
|
-
|
|
4747
|
+
input: {
|
|
4748
4748
|
type: "string",
|
|
4749
4749
|
description: "Text to convert to speech"
|
|
4750
4750
|
},
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var promises = require('fs/promises');
|
|
3
4
|
var module$1 = require('module');
|
|
5
|
+
var path = require('path');
|
|
4
6
|
var url = require('url');
|
|
5
|
-
var resolveFrom = require('resolve-from');
|
|
6
7
|
|
|
7
8
|
// src/validator/custom-resolver.ts
|
|
9
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8
10
|
function isBuiltinModule(specifier) {
|
|
9
11
|
return module$1.builtinModules.includes(specifier) || specifier.startsWith("node:") || module$1.builtinModules.includes(specifier.replace(/^node:/, ""));
|
|
10
12
|
}
|
|
11
13
|
function isRelativePath(specifier) {
|
|
12
14
|
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || /^[a-zA-Z]:\\/.test(specifier);
|
|
13
15
|
}
|
|
16
|
+
async function getParentPath(specifier, url$1) {
|
|
17
|
+
if (!cache.size) {
|
|
18
|
+
const moduleResolveMap = JSON.parse(
|
|
19
|
+
// cwd refers to the output/build directory
|
|
20
|
+
await promises.readFile(path.join(process.cwd(), "module-resolve-map.json"), "utf-8")
|
|
21
|
+
);
|
|
22
|
+
for (const [id, rest] of Object.entries(moduleResolveMap)) {
|
|
23
|
+
cache.set(url.pathToFileURL(id).toString(), rest);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const importers = cache.get(url$1);
|
|
27
|
+
if (!importers || !importers[specifier]) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const specifierParent = importers[specifier];
|
|
31
|
+
return url.pathToFileURL(specifierParent).toString();
|
|
32
|
+
}
|
|
14
33
|
async function resolve(specifier, context, nextResolve) {
|
|
15
34
|
if (isBuiltinModule(specifier)) {
|
|
16
35
|
return nextResolve(specifier, context);
|
|
@@ -18,12 +37,12 @@ async function resolve(specifier, context, nextResolve) {
|
|
|
18
37
|
if (isRelativePath(specifier)) {
|
|
19
38
|
return nextResolve(specifier, context);
|
|
20
39
|
}
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
40
|
+
if (context.parentURL) {
|
|
41
|
+
const parentPath = await getParentPath(specifier, context.parentURL);
|
|
42
|
+
if (parentPath) {
|
|
24
43
|
return nextResolve(specifier, {
|
|
25
44
|
...context,
|
|
26
|
-
parentURL:
|
|
45
|
+
parentURL: parentPath
|
|
27
46
|
});
|
|
28
47
|
}
|
|
29
48
|
}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
1
2
|
import { builtinModules } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
import { pathToFileURL } from 'node:url';
|
|
3
|
-
import { silent } from 'resolve-from';
|
|
4
5
|
|
|
5
6
|
// src/validator/custom-resolver.ts
|
|
7
|
+
var cache = /* @__PURE__ */ new Map();
|
|
6
8
|
function isBuiltinModule(specifier) {
|
|
7
9
|
return builtinModules.includes(specifier) || specifier.startsWith("node:") || builtinModules.includes(specifier.replace(/^node:/, ""));
|
|
8
10
|
}
|
|
9
11
|
function isRelativePath(specifier) {
|
|
10
12
|
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || /^[a-zA-Z]:\\/.test(specifier);
|
|
11
13
|
}
|
|
14
|
+
async function getParentPath(specifier, url) {
|
|
15
|
+
if (!cache.size) {
|
|
16
|
+
const moduleResolveMap = JSON.parse(
|
|
17
|
+
// cwd refers to the output/build directory
|
|
18
|
+
await readFile(join(process.cwd(), "module-resolve-map.json"), "utf-8")
|
|
19
|
+
);
|
|
20
|
+
for (const [id, rest] of Object.entries(moduleResolveMap)) {
|
|
21
|
+
cache.set(pathToFileURL(id).toString(), rest);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const importers = cache.get(url);
|
|
25
|
+
if (!importers || !importers[specifier]) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const specifierParent = importers[specifier];
|
|
29
|
+
return pathToFileURL(specifierParent).toString();
|
|
30
|
+
}
|
|
12
31
|
async function resolve(specifier, context, nextResolve) {
|
|
13
32
|
if (isBuiltinModule(specifier)) {
|
|
14
33
|
return nextResolve(specifier, context);
|
|
@@ -16,12 +35,12 @@ async function resolve(specifier, context, nextResolve) {
|
|
|
16
35
|
if (isRelativePath(specifier)) {
|
|
17
36
|
return nextResolve(specifier, context);
|
|
18
37
|
}
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
38
|
+
if (context.parentURL) {
|
|
39
|
+
const parentPath = await getParentPath(specifier, context.parentURL);
|
|
40
|
+
if (parentPath) {
|
|
22
41
|
return nextResolve(specifier, {
|
|
23
42
|
...context,
|
|
24
|
-
parentURL:
|
|
43
|
+
parentURL: parentPath
|
|
25
44
|
});
|
|
26
45
|
}
|
|
27
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"rollup-plugin-node-externals": "^8.0.0",
|
|
96
96
|
"typescript-paths": "^1.5.1",
|
|
97
97
|
"zod": "^3.24.2",
|
|
98
|
-
"@mastra/core": "^0.6.
|
|
98
|
+
"@mastra/core": "^0.6.4-alpha.0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@hono/node-server": "^1.13.8",
|