@mastra/deployer 1.0.0-beta.1 → 1.0.0-beta.11
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/CHANGELOG.md +200 -0
- package/dist/arktype-aI7TBD0R-4YXBEQBG.cjs +10 -0
- package/dist/arktype-aI7TBD0R-4YXBEQBG.cjs.map +1 -0
- package/dist/arktype-aI7TBD0R-OEPFT4G6.js +8 -0
- package/dist/arktype-aI7TBD0R-OEPFT4G6.js.map +1 -0
- package/dist/build/analyze/analyzeEntry.d.ts +4 -1
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.d.ts +1 -1
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +18 -13
- package/dist/build/index.d.ts +1 -0
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +5 -4
- package/dist/build/package-info.d.ts +9 -0
- package/dist/build/package-info.d.ts.map +1 -0
- package/dist/build/plugins/esm-shim.d.ts +14 -0
- package/dist/build/plugins/esm-shim.d.ts.map +1 -0
- package/dist/build/plugins/module-resolve-map.d.ts +3 -0
- package/dist/build/plugins/module-resolve-map.d.ts.map +1 -0
- package/dist/build/plugins/node-gyp-detector.d.ts +3 -0
- package/dist/build/plugins/node-gyp-detector.d.ts.map +1 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts +3 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts.map +1 -0
- package/dist/build/plugins/tsconfig-paths.d.ts +8 -0
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
- package/dist/build/utils.d.ts +13 -4
- package/dist/build/utils.d.ts.map +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.ts +1 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-H3LLQ2MW.js → chunk-3KATYU33.js} +572 -177
- package/dist/chunk-3KATYU33.js.map +1 -0
- package/dist/{chunk-WBAWUM7Z.js → chunk-5OGQ7IFB.js} +6 -5
- package/dist/chunk-5OGQ7IFB.js.map +1 -0
- package/dist/chunk-7PLNIFGZ.cjs +8 -0
- package/dist/chunk-7PLNIFGZ.cjs.map +1 -0
- package/dist/chunk-BTNPI4Z7.cjs +4 -0
- package/dist/chunk-BTNPI4Z7.cjs.map +1 -0
- package/dist/{chunk-5QFG6SCM.js → chunk-DPDWM7HQ.js} +2 -2
- package/dist/chunk-DPDWM7HQ.js.map +1 -0
- package/dist/{chunk-C74EXQSL.cjs → chunk-EHZKDGGA.cjs} +586 -190
- package/dist/chunk-EHZKDGGA.cjs.map +1 -0
- package/dist/chunk-F2LCS2DV.cjs +64 -0
- package/dist/chunk-F2LCS2DV.cjs.map +1 -0
- package/dist/chunk-FBT6QP7J.js +3 -0
- package/dist/chunk-FBT6QP7J.js.map +1 -0
- package/dist/chunk-GD2TGMBP.cjs +95 -0
- package/dist/chunk-GD2TGMBP.cjs.map +1 -0
- package/dist/{chunk-HQJR52M7.js → chunk-HFP6WWM5.js} +5 -4
- package/dist/chunk-HFP6WWM5.js.map +1 -0
- package/dist/chunk-ID3HN3BH.cjs +16 -0
- package/dist/chunk-ID3HN3BH.cjs.map +1 -0
- package/dist/{chunk-3JYRSECU.cjs → chunk-JVBCN3RH.cjs} +4 -4
- package/dist/chunk-JVBCN3RH.cjs.map +1 -0
- package/dist/chunk-MMUE22EL.js +159 -0
- package/dist/chunk-MMUE22EL.js.map +1 -0
- package/dist/chunk-N5TMJUIR.js +14 -0
- package/dist/chunk-N5TMJUIR.js.map +1 -0
- package/dist/chunk-NM6R77PX.js +57 -0
- package/dist/chunk-NM6R77PX.js.map +1 -0
- package/dist/chunk-P4L6VIHY.js +93 -0
- package/dist/chunk-P4L6VIHY.js.map +1 -0
- package/dist/{chunk-AQAOWLJJ.cjs → chunk-PK3AX3KO.cjs} +16 -15
- package/dist/chunk-PK3AX3KO.cjs.map +1 -0
- package/dist/chunk-Q2YGWEXY.js +6 -0
- package/dist/chunk-Q2YGWEXY.js.map +1 -0
- package/dist/chunk-TXKETRIN.cjs +162 -0
- package/dist/chunk-TXKETRIN.cjs.map +1 -0
- package/dist/{chunk-OFUWEVGF.js → chunk-UG72ONP7.js} +6 -15
- package/dist/chunk-UG72ONP7.js.map +1 -0
- package/dist/{chunk-TDWIGFVF.cjs → chunk-Z33LQHGJ.cjs} +15 -14
- package/dist/chunk-Z33LQHGJ.cjs.map +1 -0
- package/dist/{chunk-IL2VLNIJ.cjs → chunk-ZPUTJSEC.cjs} +13 -23
- package/dist/chunk-ZPUTJSEC.cjs.map +1 -0
- package/dist/default-u_dwuiYb-65M4BHAA.js +3 -0
- package/dist/default-u_dwuiYb-65M4BHAA.js.map +1 -0
- package/dist/default-u_dwuiYb-PWN6FHC6.cjs +9 -0
- package/dist/default-u_dwuiYb-PWN6FHC6.cjs.map +1 -0
- package/dist/deploy/log.d.ts +1 -1
- package/dist/deploy/log.d.ts.map +1 -1
- package/dist/effect-QlVUlMFu-2ADPKIDF.cjs +17 -0
- package/dist/effect-QlVUlMFu-2ADPKIDF.cjs.map +1 -0
- package/dist/effect-QlVUlMFu-FD73M3OO.js +15 -0
- package/dist/effect-QlVUlMFu-FD73M3OO.js.map +1 -0
- package/dist/esm-BLVTLTJW.js +1289 -0
- package/dist/esm-BLVTLTJW.js.map +1 -0
- package/dist/esm-E3NUCNVN.cjs +1336 -0
- package/dist/esm-E3NUCNVN.cjs.map +1 -0
- package/dist/index.cjs +12 -12
- package/dist/index.js +4 -4
- package/dist/server/handlers/restart-active-runs.d.ts +3 -0
- package/dist/server/handlers/restart-active-runs.d.ts.map +1 -0
- package/dist/server/index.cjs +2365 -10524
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +3 -12
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2363 -10522
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.js +1 -1
- package/dist/sury-CWZTCd75-K3FHMZF5.cjs +17 -0
- package/dist/sury-CWZTCd75-K3FHMZF5.cjs.map +1 -0
- package/dist/sury-CWZTCd75-Y2GURJ6K.js +15 -0
- package/dist/sury-CWZTCd75-Y2GURJ6K.js.map +1 -0
- package/dist/typebox-Dei93FPO-2WP4NOYD.js +8 -0
- package/dist/typebox-Dei93FPO-2WP4NOYD.js.map +1 -0
- package/dist/typebox-Dei93FPO-WTXAW2LA.cjs +10 -0
- package/dist/typebox-Dei93FPO-WTXAW2LA.cjs.map +1 -0
- package/dist/valibot--1zFm7rT-HMTCRBB3.cjs +17 -0
- package/dist/valibot--1zFm7rT-HMTCRBB3.cjs.map +1 -0
- package/dist/valibot--1zFm7rT-VGFBTDTW.js +15 -0
- package/dist/valibot--1zFm7rT-VGFBTDTW.js.map +1 -0
- package/dist/valibot-D_HTw1Gn-ILCWWLE4.cjs +45 -0
- package/dist/valibot-D_HTw1Gn-ILCWWLE4.cjs.map +1 -0
- package/dist/valibot-D_HTw1Gn-LLCGNU3W.js +43 -0
- package/dist/valibot-D_HTw1Gn-LLCGNU3W.js.map +1 -0
- package/dist/validator/custom-resolver.cjs +20 -12
- package/dist/validator/custom-resolver.cjs.map +1 -1
- package/dist/validator/custom-resolver.d.ts.map +1 -1
- package/dist/validator/custom-resolver.js +18 -10
- package/dist/validator/custom-resolver.js.map +1 -1
- package/dist/validator/validate.d.ts +15 -1
- package/dist/validator/validate.d.ts.map +1 -1
- package/dist/zod-Bwrt9trS-XCRGYQVE.js +29 -0
- package/dist/zod-Bwrt9trS-XCRGYQVE.js.map +1 -0
- package/dist/zod-Bwrt9trS-XDMWF3NW.cjs +31 -0
- package/dist/zod-Bwrt9trS-XDMWF3NW.cjs.map +1 -0
- package/dist/zod-DSgpEGAE-TKBHSSLS.js +37 -0
- package/dist/zod-DSgpEGAE-TKBHSSLS.js.map +1 -0
- package/dist/zod-DSgpEGAE-ZWQMF6SS.cjs +39 -0
- package/dist/zod-DSgpEGAE-ZWQMF6SS.cjs.map +1 -0
- package/package.json +18 -21
- package/dist/chunk-3JYRSECU.cjs.map +0 -1
- package/dist/chunk-5QFG6SCM.js.map +0 -1
- package/dist/chunk-AQAOWLJJ.cjs.map +0 -1
- package/dist/chunk-C74EXQSL.cjs.map +0 -1
- package/dist/chunk-H3LLQ2MW.js.map +0 -1
- package/dist/chunk-HQJR52M7.js.map +0 -1
- package/dist/chunk-IL2VLNIJ.cjs.map +0 -1
- package/dist/chunk-OFUWEVGF.js.map +0 -1
- package/dist/chunk-TDWIGFVF.cjs.map +0 -1
- package/dist/chunk-WBAWUM7Z.js.map +0 -1
- package/dist/server/handlers/auth/defaults.d.ts +0 -3
- package/dist/server/handlers/auth/defaults.d.ts.map +0 -1
- package/dist/server/handlers/auth/helpers.d.ts +0 -11
- package/dist/server/handlers/auth/helpers.d.ts.map +0 -1
- package/dist/server/handlers/auth/index.d.ts +0 -11
- package/dist/server/handlers/auth/index.d.ts.map +0 -1
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts +0 -20
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/agent-builder/router.d.ts +0 -4
- package/dist/server/handlers/routes/agent-builder/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/handlers.d.ts +0 -232
- package/dist/server/handlers/routes/agents/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/router.d.ts +0 -5
- package/dist/server/handlers/routes/agents/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/voice.d.ts +0 -18
- package/dist/server/handlers/routes/agents/voice.d.ts.map +0 -1
- package/dist/server/handlers/routes/logs/handlers.d.ts +0 -5
- package/dist/server/handlers/routes/logs/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/logs/router.d.ts +0 -3
- package/dist/server/handlers/routes/logs/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/mcp/handlers.d.ts +0 -139
- package/dist/server/handlers/routes/mcp/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/mcp/router.d.ts +0 -4
- package/dist/server/handlers/routes/mcp/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/memory/handlers.d.ts +0 -15
- package/dist/server/handlers/routes/memory/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/memory/router.d.ts +0 -4
- package/dist/server/handlers/routes/memory/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/observability/handlers.d.ts +0 -6
- package/dist/server/handlers/routes/observability/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/observability/router.d.ts +0 -3
- package/dist/server/handlers/routes/observability/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/scores/handlers.d.ts +0 -302
- package/dist/server/handlers/routes/scores/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/scores/router.d.ts +0 -4
- package/dist/server/handlers/routes/scores/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/tools/handlers.d.ts +0 -7
- package/dist/server/handlers/routes/tools/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/tools/router.d.ts +0 -4
- package/dist/server/handlers/routes/tools/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/vector/handlers.d.ts +0 -10
- package/dist/server/handlers/routes/vector/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/vector/router.d.ts +0 -4
- package/dist/server/handlers/routes/vector/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/handlers.d.ts +0 -20
- package/dist/server/handlers/routes/workflows/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/router.d.ts +0 -4
- package/dist/server/handlers/routes/workflows/router.d.ts.map +0 -1
|
@@ -1,107 +1,44 @@
|
|
|
1
|
+
import { slash, isDependencyPartOfPackage, getPackageName, getCompiledDepCachePath, rollupSafeName } from './chunk-NM6R77PX.js';
|
|
1
2
|
import * as babel from '@babel/core';
|
|
2
3
|
import babel__default from '@babel/core';
|
|
3
4
|
import fs, { existsSync } from 'fs';
|
|
4
5
|
import { readFile, writeFile } from 'fs/promises';
|
|
5
6
|
import * as path2 from 'path';
|
|
6
|
-
import path2__default, { dirname, join, normalize,
|
|
7
|
+
import path2__default, { dirname, join, normalize, basename as basename$1 } from 'path';
|
|
7
8
|
import { spawn as spawn$1 } from 'child_process';
|
|
8
|
-
import { getPackageInfo } from 'local-pkg';
|
|
9
|
-
import { pathToFileURL, fileURLToPath } from 'url';
|
|
10
9
|
import { rollup } from 'rollup';
|
|
11
10
|
import originalEsbuild from 'rollup-plugin-esbuild';
|
|
12
11
|
import commonjs from '@rollup/plugin-commonjs';
|
|
13
12
|
import resolveFrom2 from 'resolve-from';
|
|
13
|
+
import stripJsonComments from 'strip-json-comments';
|
|
14
14
|
import { createHandler } from 'typescript-paths';
|
|
15
15
|
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
|
|
16
16
|
import json from '@rollup/plugin-json';
|
|
17
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
17
18
|
import * as pkg from 'empathic/package';
|
|
18
19
|
import { createWorkspacesCache, findWorkspaces, findWorkspacesRoot } from 'find-workspaces';
|
|
19
20
|
import { noopLogger } from '@mastra/core/logger';
|
|
20
21
|
import virtual from '@rollup/plugin-virtual';
|
|
21
22
|
import { builtinModules } from 'module';
|
|
23
|
+
import { getPackageInfo } from 'local-pkg';
|
|
22
24
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
23
|
-
import
|
|
25
|
+
import originalEsmShim from '@rollup/plugin-esm-shim';
|
|
24
26
|
import { basename } from 'path/posix';
|
|
25
27
|
import * as resolve from 'resolve.exports';
|
|
26
28
|
import { MastraBaseError, ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
async function getPackageRootPath(packageName, parentPath) {
|
|
37
|
-
let rootPath;
|
|
38
|
-
try {
|
|
39
|
-
let options = void 0;
|
|
40
|
-
if (parentPath) {
|
|
41
|
-
if (!parentPath.startsWith("file://")) {
|
|
42
|
-
parentPath = pathToFileURL(parentPath).href;
|
|
43
|
-
}
|
|
44
|
-
options = {
|
|
45
|
-
paths: [parentPath]
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const pkg2 = await getPackageInfo(packageName, options);
|
|
49
|
-
rootPath = pkg2?.rootPath ?? null;
|
|
50
|
-
} catch (e) {
|
|
51
|
-
rootPath = null;
|
|
30
|
+
var ValidationError = class extends Error {
|
|
31
|
+
type;
|
|
32
|
+
stack;
|
|
33
|
+
constructor(args) {
|
|
34
|
+
super(args.message);
|
|
35
|
+
this.type = args.type;
|
|
36
|
+
this.stack = args.stack;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
function getCompiledDepCachePath(rootPath, packageName) {
|
|
56
|
-
return slash(join(rootPath, "node_modules", ".cache", packageName));
|
|
57
|
-
}
|
|
58
|
-
function slash(path3) {
|
|
59
|
-
const isExtendedLengthPath = path3.startsWith("\\\\?\\");
|
|
60
|
-
if (isExtendedLengthPath) {
|
|
61
|
-
return path3;
|
|
62
|
-
}
|
|
63
|
-
return path3.replaceAll("\\", "/");
|
|
64
|
-
}
|
|
65
|
-
function rollupSafeName(name, rootDir) {
|
|
66
|
-
const rel = relative(rootDir, name);
|
|
67
|
-
let entry = slash(rel);
|
|
68
|
-
entry = entry.replace(/^(\.\.\/)+/, "");
|
|
69
|
-
entry = entry.replace(/^\/+/, "");
|
|
70
|
-
entry = entry.replace(/^[A-Za-z]:\//, "");
|
|
71
|
-
if (!entry) {
|
|
72
|
-
entry = slash(basename$1(name));
|
|
73
|
-
}
|
|
74
|
-
return entry;
|
|
75
|
-
}
|
|
76
|
-
var NATIVE_BINDING_LOADERS = [
|
|
77
|
-
"node-gyp-build",
|
|
78
|
-
"prebuild-install",
|
|
79
|
-
"bindings",
|
|
80
|
-
"node-addon-api",
|
|
81
|
-
"node-pre-gyp",
|
|
82
|
-
"nan"
|
|
83
|
-
// Native Abstractions for Node.js
|
|
84
|
-
];
|
|
85
|
-
function findNativePackageModule(moduleIds) {
|
|
86
|
-
return moduleIds.find((id) => {
|
|
87
|
-
if (id.startsWith("\0")) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (!id.includes("/node_modules/")) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
for (const loader of NATIVE_BINDING_LOADERS) {
|
|
94
|
-
if (id.includes(`/${loader}/`) || id.includes(`/${loader}@`)) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// src/validator/validate.ts
|
|
38
|
+
};
|
|
103
39
|
function spawn(command, args = [], options = {}) {
|
|
104
40
|
return new Promise((resolve2, reject) => {
|
|
41
|
+
let validationError = null;
|
|
105
42
|
const childProcess = spawn$1(command, args, {
|
|
106
43
|
// stdio: 'inherit',
|
|
107
44
|
...options
|
|
@@ -111,28 +48,63 @@ function spawn(command, args = [], options = {}) {
|
|
|
111
48
|
});
|
|
112
49
|
let stderr = "";
|
|
113
50
|
childProcess.stderr?.on("data", (message) => {
|
|
114
|
-
|
|
51
|
+
try {
|
|
52
|
+
validationError = JSON.parse(message.toString());
|
|
53
|
+
} catch {
|
|
54
|
+
stderr += message;
|
|
55
|
+
}
|
|
115
56
|
});
|
|
116
57
|
childProcess.on("close", (code) => {
|
|
117
58
|
if (code === 0) {
|
|
118
59
|
resolve2();
|
|
119
60
|
} else {
|
|
120
|
-
|
|
61
|
+
if (validationError) {
|
|
62
|
+
reject(new ValidationError(validationError));
|
|
63
|
+
} else {
|
|
64
|
+
reject(new Error(stderr));
|
|
65
|
+
}
|
|
121
66
|
}
|
|
122
67
|
});
|
|
123
68
|
});
|
|
124
69
|
}
|
|
125
|
-
function validate(file) {
|
|
70
|
+
function validate(file, { injectESMShim = false, moduleResolveMapLocation }) {
|
|
71
|
+
let prefixCode = "";
|
|
72
|
+
if (injectESMShim) {
|
|
73
|
+
prefixCode = `import { fileURLToPath } from 'url';
|
|
74
|
+
import { dirname } from 'path';
|
|
75
|
+
|
|
76
|
+
globalThis.__filename = fileURLToPath(import.meta.url);
|
|
77
|
+
globalThis.__dirname = dirname(__filename);
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
function errorHandler(err) {
|
|
81
|
+
console.error(
|
|
82
|
+
JSON.stringify({
|
|
83
|
+
type: err.name,
|
|
84
|
+
message: err.message,
|
|
85
|
+
stack: err.stack
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
126
90
|
return spawn(
|
|
127
|
-
|
|
91
|
+
process.execPath,
|
|
128
92
|
[
|
|
129
93
|
"--import",
|
|
130
94
|
import.meta.resolve("@mastra/deployer/loader"),
|
|
131
95
|
"--input-type=module",
|
|
96
|
+
"--enable-source-maps",
|
|
132
97
|
"-e",
|
|
133
|
-
|
|
98
|
+
`${prefixCode};import('file://${slash(file)}').catch(err => {
|
|
99
|
+
${errorHandler.toString()}
|
|
100
|
+
errorHandler(err);
|
|
101
|
+
})`.replaceAll(/\n/g, "")
|
|
134
102
|
],
|
|
135
103
|
{
|
|
104
|
+
env: {
|
|
105
|
+
...process.env,
|
|
106
|
+
MODULE_MAP: `${moduleResolveMapLocation}`
|
|
107
|
+
},
|
|
136
108
|
cwd: dirname(file)
|
|
137
109
|
}
|
|
138
110
|
);
|
|
@@ -227,29 +199,90 @@ function esbuild(options = {}) {
|
|
|
227
199
|
});
|
|
228
200
|
}
|
|
229
201
|
var PLUGIN_NAME = "tsconfig-paths";
|
|
202
|
+
function hasPaths(tsConfigPath) {
|
|
203
|
+
try {
|
|
204
|
+
const content = fs.readFileSync(tsConfigPath, "utf8");
|
|
205
|
+
const config = JSON.parse(stripJsonComments(content));
|
|
206
|
+
return !!(config.compilerOptions?.paths && Object.keys(config.compilerOptions.paths).length > 0);
|
|
207
|
+
} catch {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
230
211
|
function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
|
|
231
|
-
|
|
212
|
+
const handlerCache = /* @__PURE__ */ new Map();
|
|
213
|
+
function findTsConfigForFile(filePath) {
|
|
214
|
+
let currentDir = path2__default.dirname(filePath);
|
|
215
|
+
const root = path2__default.parse(currentDir).root;
|
|
216
|
+
while (currentDir !== root) {
|
|
217
|
+
const tsConfigPath2 = path2__default.join(currentDir, "tsconfig.json");
|
|
218
|
+
if (fs.existsSync(tsConfigPath2)) {
|
|
219
|
+
if (hasPaths(tsConfigPath2)) {
|
|
220
|
+
return tsConfigPath2;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const tsConfigBasePath = path2__default.join(currentDir, "tsconfig.base.json");
|
|
224
|
+
if (fs.existsSync(tsConfigBasePath)) {
|
|
225
|
+
if (hasPaths(tsConfigBasePath)) {
|
|
226
|
+
return tsConfigBasePath;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
currentDir = path2__default.dirname(currentDir);
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
function getHandlerForFile(filePath) {
|
|
234
|
+
if (tsConfigPath && typeof tsConfigPath === "string") {
|
|
235
|
+
if (!handlerCache.has(tsConfigPath)) {
|
|
236
|
+
handlerCache.set(
|
|
237
|
+
tsConfigPath,
|
|
238
|
+
createHandler({
|
|
239
|
+
log: () => {
|
|
240
|
+
},
|
|
241
|
+
tsConfigPath,
|
|
242
|
+
respectCoreModule,
|
|
243
|
+
falllback: (moduleName) => fs.existsSync(moduleName)
|
|
244
|
+
})
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
return handlerCache.get(tsConfigPath);
|
|
248
|
+
}
|
|
249
|
+
const configPath = findTsConfigForFile(filePath);
|
|
250
|
+
if (!configPath) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
if (!handlerCache.has(configPath)) {
|
|
254
|
+
handlerCache.set(
|
|
255
|
+
configPath,
|
|
256
|
+
createHandler({
|
|
257
|
+
log: () => {
|
|
258
|
+
},
|
|
259
|
+
tsConfigPath: configPath,
|
|
260
|
+
respectCoreModule,
|
|
261
|
+
falllback: (moduleName) => fs.existsSync(moduleName)
|
|
262
|
+
})
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
return handlerCache.get(configPath);
|
|
266
|
+
}
|
|
267
|
+
function resolveAlias(request, importer) {
|
|
268
|
+
const dynamicHandler = getHandlerForFile(importer);
|
|
269
|
+
if (!dynamicHandler) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const resolved = dynamicHandler(request, normalize(importer));
|
|
273
|
+
return resolved;
|
|
274
|
+
}
|
|
232
275
|
return {
|
|
233
276
|
name: PLUGIN_NAME,
|
|
234
|
-
buildStart() {
|
|
235
|
-
handler = createHandler({
|
|
236
|
-
log: () => {
|
|
237
|
-
},
|
|
238
|
-
tsConfigPath,
|
|
239
|
-
respectCoreModule,
|
|
240
|
-
falllback: (moduleName) => fs.existsSync(moduleName)
|
|
241
|
-
});
|
|
242
|
-
return;
|
|
243
|
-
},
|
|
244
277
|
async resolveId(request, importer, options) {
|
|
245
|
-
if (!importer || request.startsWith("\0")) {
|
|
278
|
+
if (!importer || request.startsWith("\0") || importer.charCodeAt(0) === 0) {
|
|
246
279
|
return null;
|
|
247
280
|
}
|
|
248
|
-
const moduleName =
|
|
281
|
+
const moduleName = resolveAlias(request, importer);
|
|
249
282
|
if (!moduleName) {
|
|
250
283
|
let importerMeta = {};
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
284
|
+
const resolved2 = await this.resolve(request, importer, { skipSelf: true, ...options });
|
|
285
|
+
if (!resolved2) {
|
|
253
286
|
return null;
|
|
254
287
|
}
|
|
255
288
|
if (localResolve) {
|
|
@@ -257,37 +290,42 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
|
|
|
257
290
|
importerMeta = importerInfo?.meta || {};
|
|
258
291
|
if (!request.startsWith("./") && !request.startsWith("../") && importerMeta?.[PLUGIN_NAME]?.resolved) {
|
|
259
292
|
return {
|
|
260
|
-
...
|
|
293
|
+
...resolved2,
|
|
261
294
|
external: !request.startsWith("hono/") && request !== "hono"
|
|
262
295
|
};
|
|
263
296
|
}
|
|
264
297
|
}
|
|
265
298
|
return {
|
|
266
|
-
...
|
|
299
|
+
...resolved2,
|
|
267
300
|
meta: {
|
|
268
|
-
...
|
|
301
|
+
...resolved2.meta || {},
|
|
269
302
|
...importerMeta
|
|
270
303
|
}
|
|
271
304
|
};
|
|
272
305
|
}
|
|
273
306
|
if (!path2__default.extname(moduleName)) {
|
|
274
|
-
const
|
|
275
|
-
if (!
|
|
307
|
+
const resolved2 = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
|
|
308
|
+
if (!resolved2) {
|
|
276
309
|
return null;
|
|
277
310
|
}
|
|
278
311
|
return {
|
|
279
|
-
...
|
|
312
|
+
...resolved2,
|
|
280
313
|
meta: {
|
|
281
|
-
...
|
|
314
|
+
...resolved2.meta,
|
|
282
315
|
[PLUGIN_NAME]: {
|
|
283
316
|
resolved: true
|
|
284
317
|
}
|
|
285
318
|
}
|
|
286
319
|
};
|
|
287
320
|
}
|
|
321
|
+
const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
|
|
322
|
+
if (!resolved) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
288
325
|
return {
|
|
289
|
-
|
|
326
|
+
...resolved,
|
|
290
327
|
meta: {
|
|
328
|
+
...resolved.meta,
|
|
291
329
|
[PLUGIN_NAME]: {
|
|
292
330
|
resolved: true
|
|
293
331
|
}
|
|
@@ -448,7 +486,7 @@ async function extractMastraOption(name, entryFile, transformer, outputDir, logg
|
|
|
448
486
|
const configPath = `${outputDir}/${name}-config.mjs`;
|
|
449
487
|
return {
|
|
450
488
|
bundleOutput: output,
|
|
451
|
-
getConfig: () => import(
|
|
489
|
+
getConfig: () => import(pathToFileURL(configPath).href).then((m) => m[name])
|
|
452
490
|
};
|
|
453
491
|
}
|
|
454
492
|
return null;
|
|
@@ -604,6 +642,25 @@ function removeDeployer2(mastraEntry, options) {
|
|
|
604
642
|
}
|
|
605
643
|
};
|
|
606
644
|
}
|
|
645
|
+
async function getPackageRootPath(packageName, parentPath) {
|
|
646
|
+
let rootPath;
|
|
647
|
+
try {
|
|
648
|
+
let options = void 0;
|
|
649
|
+
if (parentPath) {
|
|
650
|
+
if (!parentPath.startsWith("file://")) {
|
|
651
|
+
parentPath = pathToFileURL(parentPath).href;
|
|
652
|
+
}
|
|
653
|
+
options = {
|
|
654
|
+
paths: [parentPath]
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
const pkg2 = await getPackageInfo(packageName, options);
|
|
658
|
+
rootPath = pkg2?.rootPath ?? null;
|
|
659
|
+
} catch (e) {
|
|
660
|
+
rootPath = null;
|
|
661
|
+
}
|
|
662
|
+
return rootPath;
|
|
663
|
+
}
|
|
607
664
|
|
|
608
665
|
// src/build/analyze/constants.ts
|
|
609
666
|
var DEPS_TO_IGNORE = ["#tools"];
|
|
@@ -666,7 +723,8 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
|
|
|
666
723
|
return plugins;
|
|
667
724
|
}
|
|
668
725
|
async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, initialDepsToOptimize, {
|
|
669
|
-
logger
|
|
726
|
+
logger,
|
|
727
|
+
shouldCheckTransitiveDependencies
|
|
670
728
|
}) {
|
|
671
729
|
const depsToOptimize = /* @__PURE__ */ new Map();
|
|
672
730
|
if (!output.facadeModuleId) {
|
|
@@ -679,7 +737,7 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
679
737
|
entryRootPath = await getPackageRootPath(output.facadeModuleId) || projectRoot;
|
|
680
738
|
}
|
|
681
739
|
for (const [dependency, bindings] of Object.entries(output.importedBindings)) {
|
|
682
|
-
if (isNodeBuiltin(dependency) ||
|
|
740
|
+
if (isNodeBuiltin(dependency) || dependency.startsWith("#")) {
|
|
683
741
|
continue;
|
|
684
742
|
}
|
|
685
743
|
const pkgName = getPackageName(dependency);
|
|
@@ -690,7 +748,11 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
690
748
|
isWorkspace = workspaceMap.has(pkgName);
|
|
691
749
|
}
|
|
692
750
|
const normalizedRootPath = rootPath ? slash(rootPath) : null;
|
|
693
|
-
depsToOptimize.set(dependency, {
|
|
751
|
+
depsToOptimize.set(dependency, {
|
|
752
|
+
exports: bindings,
|
|
753
|
+
rootPath: normalizedRootPath,
|
|
754
|
+
isWorkspace
|
|
755
|
+
});
|
|
694
756
|
}
|
|
695
757
|
async function checkTransitiveDependencies(internalMap, maxDepth = 10, currentDepth = 0) {
|
|
696
758
|
if (currentDepth >= maxDepth) {
|
|
@@ -734,12 +796,18 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
734
796
|
await checkTransitiveDependencies(internalMap, maxDepth, currentDepth + 1);
|
|
735
797
|
}
|
|
736
798
|
}
|
|
737
|
-
|
|
799
|
+
if (shouldCheckTransitiveDependencies) {
|
|
800
|
+
await checkTransitiveDependencies(initialDepsToOptimize);
|
|
801
|
+
}
|
|
738
802
|
const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
|
|
739
803
|
if (dynamicImports.length) {
|
|
740
804
|
for (const dynamicImport of dynamicImports) {
|
|
741
805
|
if (!depsToOptimize.has(dynamicImport) && !isNodeBuiltin(dynamicImport)) {
|
|
742
|
-
depsToOptimize.set(dynamicImport, {
|
|
806
|
+
depsToOptimize.set(dynamicImport, {
|
|
807
|
+
exports: ["*"],
|
|
808
|
+
rootPath: null,
|
|
809
|
+
isWorkspace: false
|
|
810
|
+
});
|
|
743
811
|
}
|
|
744
812
|
}
|
|
745
813
|
}
|
|
@@ -753,13 +821,14 @@ async function analyzeEntry({
|
|
|
753
821
|
sourcemapEnabled,
|
|
754
822
|
workspaceMap,
|
|
755
823
|
projectRoot,
|
|
756
|
-
initialDepsToOptimize = /* @__PURE__ */ new Map()
|
|
824
|
+
initialDepsToOptimize = /* @__PURE__ */ new Map(),
|
|
757
825
|
// used to avoid infinite recursion
|
|
826
|
+
shouldCheckTransitiveDependencies = false
|
|
758
827
|
}) {
|
|
759
828
|
const optimizerBundler = await rollup({
|
|
760
829
|
logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
|
|
761
830
|
input: isVirtualFile ? "#entry" : entry,
|
|
762
|
-
treeshake:
|
|
831
|
+
treeshake: false,
|
|
763
832
|
preserveSymlinks: true,
|
|
764
833
|
plugins: getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }),
|
|
765
834
|
external: DEPS_TO_IGNORE
|
|
@@ -775,7 +844,8 @@ async function analyzeEntry({
|
|
|
775
844
|
projectRoot,
|
|
776
845
|
initialDepsToOptimize,
|
|
777
846
|
{
|
|
778
|
-
logger
|
|
847
|
+
logger,
|
|
848
|
+
shouldCheckTransitiveDependencies
|
|
779
849
|
}
|
|
780
850
|
);
|
|
781
851
|
return {
|
|
@@ -786,6 +856,27 @@ async function analyzeEntry({
|
|
|
786
856
|
}
|
|
787
857
|
};
|
|
788
858
|
}
|
|
859
|
+
var FilenameDeclarationRegex = /(?:const|let|var)\s+__filename/;
|
|
860
|
+
var DirnameDeclarationRegex = /(?:const|let|var)\s+__dirname/;
|
|
861
|
+
function esmShim() {
|
|
862
|
+
const original = originalEsmShim();
|
|
863
|
+
return {
|
|
864
|
+
name: "esm-shim",
|
|
865
|
+
renderChunk(code, chunk, opts, meta) {
|
|
866
|
+
const hasFilename = code.includes("__filename");
|
|
867
|
+
const hasDirname = code.includes("__dirname");
|
|
868
|
+
const userDeclaredFilename = hasFilename && FilenameDeclarationRegex.test(code);
|
|
869
|
+
const userDeclaredDirname = hasDirname && DirnameDeclarationRegex.test(code);
|
|
870
|
+
if (userDeclaredFilename || userDeclaredDirname) {
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
if (typeof original.renderChunk === "function") {
|
|
874
|
+
return original.renderChunk.call(this, code, chunk, opts, meta);
|
|
875
|
+
}
|
|
876
|
+
return null;
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
}
|
|
789
880
|
function aliasHono() {
|
|
790
881
|
return {
|
|
791
882
|
name: "hono-alias",
|
|
@@ -798,6 +889,114 @@ function aliasHono() {
|
|
|
798
889
|
}
|
|
799
890
|
};
|
|
800
891
|
}
|
|
892
|
+
function nodeGypDetector() {
|
|
893
|
+
const modulesToTrack = /* @__PURE__ */ new Set();
|
|
894
|
+
const modulesToTrackPackageInfo = /* @__PURE__ */ new Map();
|
|
895
|
+
return {
|
|
896
|
+
name: "node-gyp-build-detector",
|
|
897
|
+
moduleParsed(info) {
|
|
898
|
+
if (!info.meta?.commonjs?.requires?.length) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
const hasNodeGypBuild = info.meta.commonjs.requires.some(
|
|
902
|
+
(m) => m?.resolved?.id.endsWith("node-gyp-build/index.js")
|
|
903
|
+
);
|
|
904
|
+
if (!hasNodeGypBuild) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
modulesToTrack.add(info.id);
|
|
908
|
+
modulesToTrackPackageInfo.set(info.id, getPackageInfo(info.id));
|
|
909
|
+
},
|
|
910
|
+
async generateBundle(options, bundle) {
|
|
911
|
+
const binaryMapByChunk = /* @__PURE__ */ new Map();
|
|
912
|
+
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
913
|
+
if (chunk.type === "chunk") {
|
|
914
|
+
for (const moduleId of chunk.moduleIds) {
|
|
915
|
+
if (modulesToTrackPackageInfo.has(moduleId)) {
|
|
916
|
+
const pkgInfo = await modulesToTrackPackageInfo.get(moduleId);
|
|
917
|
+
if (!binaryMapByChunk.has(fileName)) {
|
|
918
|
+
binaryMapByChunk.set(fileName, /* @__PURE__ */ new Set());
|
|
919
|
+
}
|
|
920
|
+
if (pkgInfo?.packageJson?.name) {
|
|
921
|
+
binaryMapByChunk.get(fileName).add(pkgInfo.packageJson.name);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
const binaryMapJson = Object.fromEntries(
|
|
928
|
+
Array.from(binaryMapByChunk.entries()).map(([key, value]) => [key, Array.from(value)])
|
|
929
|
+
);
|
|
930
|
+
this.emitFile({
|
|
931
|
+
type: "asset",
|
|
932
|
+
name: "binary-map.json",
|
|
933
|
+
source: `${JSON.stringify(binaryMapJson, null, 2)}`
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// src/build/plugins/subpath-externals-resolver.ts
|
|
940
|
+
function subpathExternalsResolver(externals) {
|
|
941
|
+
return {
|
|
942
|
+
name: "subpath-externals-resolver",
|
|
943
|
+
resolveId(id) {
|
|
944
|
+
if (id.startsWith(".") || id.startsWith("/")) {
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
const isPartOfExternals = externals.some((external) => isDependencyPartOfPackage(id, external));
|
|
948
|
+
if (isPartOfExternals) {
|
|
949
|
+
return {
|
|
950
|
+
id,
|
|
951
|
+
external: true
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function moduleResolveMap(externals, projectRoot) {
|
|
958
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
959
|
+
return {
|
|
960
|
+
name: "module-resolve-map",
|
|
961
|
+
moduleParsed(info) {
|
|
962
|
+
if (info.importedIds.length === 0 || !info.id) {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
for (const importedId of info.importedIds) {
|
|
966
|
+
for (const external of externals) {
|
|
967
|
+
if (isDependencyPartOfPackage(importedId, external)) {
|
|
968
|
+
importMap.set(external, info.id);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
async generateBundle(options, bundle) {
|
|
974
|
+
const resolveMap = /* @__PURE__ */ new Map();
|
|
975
|
+
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
976
|
+
if (chunk.type === "chunk") {
|
|
977
|
+
for (const [external, resolvedFrom] of importMap) {
|
|
978
|
+
if (chunk.moduleIds.includes(resolvedFrom)) {
|
|
979
|
+
const fullPath = pathToFileURL(slash(join(projectRoot, fileName))).toString();
|
|
980
|
+
const innerMap = resolveMap.get(fullPath) || /* @__PURE__ */ new Map();
|
|
981
|
+
innerMap.set(external, pathToFileURL(slash(resolvedFrom)).toString());
|
|
982
|
+
resolveMap.set(fullPath, innerMap);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
const resolveMapJson = Object.fromEntries(
|
|
988
|
+
Array.from(resolveMap.entries()).map(([key, value]) => [key, Object.fromEntries(value.entries())])
|
|
989
|
+
);
|
|
990
|
+
this.emitFile({
|
|
991
|
+
type: "asset",
|
|
992
|
+
name: "module-resolve-map.json",
|
|
993
|
+
source: `${JSON.stringify(resolveMapJson, null, 2)}`
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// src/build/analyze/bundleExternals.ts
|
|
801
1000
|
function prepareEntryFileName(name, rootDir) {
|
|
802
1001
|
return rollupSafeName(name, rootDir);
|
|
803
1002
|
}
|
|
@@ -863,7 +1062,8 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
863
1062
|
transpilePackages,
|
|
864
1063
|
workspaceMap,
|
|
865
1064
|
bundlerOptions,
|
|
866
|
-
rootDir
|
|
1065
|
+
rootDir,
|
|
1066
|
+
externals
|
|
867
1067
|
}) {
|
|
868
1068
|
const transpilePackagesMap = /* @__PURE__ */ new Map();
|
|
869
1069
|
for (const pkg2 of transpilePackages) {
|
|
@@ -884,6 +1084,7 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
884
1084
|
{}
|
|
885
1085
|
)
|
|
886
1086
|
),
|
|
1087
|
+
subpathExternalsResolver(externals),
|
|
887
1088
|
transpilePackagesMap.size ? esbuild({
|
|
888
1089
|
format: "esm",
|
|
889
1090
|
include: [...transpilePackagesMap.values()].map((p) => {
|
|
@@ -912,7 +1113,8 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
912
1113
|
if (!resolvedPath) {
|
|
913
1114
|
resolvedPath = pkgJson.main ?? "index.js";
|
|
914
1115
|
}
|
|
915
|
-
|
|
1116
|
+
const resolved = await this.resolve(path2.posix.join(packageRootPath, resolvedPath), importer, options);
|
|
1117
|
+
return resolved;
|
|
916
1118
|
}
|
|
917
1119
|
} : null,
|
|
918
1120
|
optimizeLodashImports({
|
|
@@ -931,6 +1133,8 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
931
1133
|
// hono is imported from deployer, so we need to resolve from here instead of the project root
|
|
932
1134
|
aliasHono(),
|
|
933
1135
|
json(),
|
|
1136
|
+
nodeGypDetector(),
|
|
1137
|
+
moduleResolveMap(externals, rootDir),
|
|
934
1138
|
{
|
|
935
1139
|
name: "not-found-resolver",
|
|
936
1140
|
resolveId: {
|
|
@@ -988,12 +1192,13 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
988
1192
|
{}
|
|
989
1193
|
),
|
|
990
1194
|
external: externals,
|
|
991
|
-
treeshake: "safest",
|
|
1195
|
+
treeshake: bundlerOptions.isDev ? false : "safest",
|
|
992
1196
|
plugins: getInputPlugins2(virtualDependencies, {
|
|
993
1197
|
transpilePackages: packagesToTranspile,
|
|
994
1198
|
workspaceMap,
|
|
995
1199
|
bundlerOptions,
|
|
996
|
-
rootDir
|
|
1200
|
+
rootDir,
|
|
1201
|
+
externals
|
|
997
1202
|
})
|
|
998
1203
|
});
|
|
999
1204
|
const outputDirRelative = prepareEntryFileName(outputDir, rootDir);
|
|
@@ -1001,6 +1206,8 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1001
1206
|
format: "esm",
|
|
1002
1207
|
dir: rootDir,
|
|
1003
1208
|
entryFileNames: "[name].mjs",
|
|
1209
|
+
// used to get the filename of the actual error
|
|
1210
|
+
sourcemap: true,
|
|
1004
1211
|
/**
|
|
1005
1212
|
* Rollup creates chunks for common dependencies, but these chunks are by default written to the root directory instead of respecting the entryFileNames structure.
|
|
1006
1213
|
* So we want to write them to the `.mastra/output` folder as well.
|
|
@@ -1038,6 +1245,7 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1038
1245
|
}
|
|
1039
1246
|
return `${outputDirRelative}/[name].mjs`;
|
|
1040
1247
|
},
|
|
1248
|
+
assetFileNames: `${outputDirRelative}/[name][extname]`,
|
|
1041
1249
|
hoistTransitiveImports: false
|
|
1042
1250
|
});
|
|
1043
1251
|
await bundler.close();
|
|
@@ -1046,7 +1254,7 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1046
1254
|
function findExternalImporter(module, external, allOutputs) {
|
|
1047
1255
|
const capturedFiles = /* @__PURE__ */ new Set();
|
|
1048
1256
|
for (const id of module.imports) {
|
|
1049
|
-
if (id
|
|
1257
|
+
if (isDependencyPartOfPackage(id, external)) {
|
|
1050
1258
|
return module;
|
|
1051
1259
|
} else {
|
|
1052
1260
|
if (id.endsWith(".mjs")) {
|
|
@@ -1092,7 +1300,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1092
1300
|
isDev
|
|
1093
1301
|
}
|
|
1094
1302
|
});
|
|
1095
|
-
const
|
|
1303
|
+
const moduleResolveMap2 = /* @__PURE__ */ new Map();
|
|
1096
1304
|
const filteredChunks = output.filter((o) => o.type === "chunk");
|
|
1097
1305
|
for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
|
|
1098
1306
|
for (const external of allExternals) {
|
|
@@ -1102,10 +1310,10 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1102
1310
|
const importer = findExternalImporter(o, external, filteredChunks);
|
|
1103
1311
|
if (importer) {
|
|
1104
1312
|
const fullPath = path2.join(workspaceRoot || projectRoot, importer.fileName);
|
|
1105
|
-
let innerMap =
|
|
1313
|
+
let innerMap = moduleResolveMap2.get(fullPath);
|
|
1106
1314
|
if (!innerMap) {
|
|
1107
1315
|
innerMap = /* @__PURE__ */ new Map();
|
|
1108
|
-
|
|
1316
|
+
moduleResolveMap2.set(fullPath, innerMap);
|
|
1109
1317
|
}
|
|
1110
1318
|
if (importer.moduleIds.length) {
|
|
1111
1319
|
innerMap.set(
|
|
@@ -1117,7 +1325,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1117
1325
|
}
|
|
1118
1326
|
}
|
|
1119
1327
|
const usedExternals = /* @__PURE__ */ Object.create(null);
|
|
1120
|
-
for (const [fullPath, innerMap] of
|
|
1328
|
+
for (const [fullPath, innerMap] of moduleResolveMap2) {
|
|
1121
1329
|
const innerObj = /* @__PURE__ */ Object.create(null);
|
|
1122
1330
|
for (const [external, value] of innerMap) {
|
|
1123
1331
|
innerObj[external] = value;
|
|
@@ -1126,6 +1334,108 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1126
1334
|
}
|
|
1127
1335
|
return { output, fileNameToDependencyMap, usedExternals };
|
|
1128
1336
|
}
|
|
1337
|
+
|
|
1338
|
+
// ../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js
|
|
1339
|
+
var UNKNOWN_FUNCTION = "<unknown>";
|
|
1340
|
+
function parse(stackString) {
|
|
1341
|
+
var lines = stackString.split("\n");
|
|
1342
|
+
return lines.reduce(function(stack, line) {
|
|
1343
|
+
var parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
|
|
1344
|
+
if (parseResult) {
|
|
1345
|
+
stack.push(parseResult);
|
|
1346
|
+
}
|
|
1347
|
+
return stack;
|
|
1348
|
+
}, []);
|
|
1349
|
+
}
|
|
1350
|
+
var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|rsc|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
1351
|
+
var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
|
1352
|
+
function parseChrome(line) {
|
|
1353
|
+
var parts = chromeRe.exec(line);
|
|
1354
|
+
if (!parts) {
|
|
1355
|
+
return null;
|
|
1356
|
+
}
|
|
1357
|
+
var isNative = parts[2] && parts[2].indexOf("native") === 0;
|
|
1358
|
+
var isEval = parts[2] && parts[2].indexOf("eval") === 0;
|
|
1359
|
+
var submatch = chromeEvalRe.exec(parts[2]);
|
|
1360
|
+
if (isEval && submatch != null) {
|
|
1361
|
+
parts[2] = submatch[1];
|
|
1362
|
+
parts[3] = submatch[2];
|
|
1363
|
+
parts[4] = submatch[3];
|
|
1364
|
+
}
|
|
1365
|
+
return {
|
|
1366
|
+
file: !isNative ? parts[2] : null,
|
|
1367
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1368
|
+
arguments: isNative ? [parts[2]] : [],
|
|
1369
|
+
lineNumber: parts[3] ? +parts[3] : null,
|
|
1370
|
+
column: parts[4] ? +parts[4] : null
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|rsc|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1374
|
+
function parseWinjs(line) {
|
|
1375
|
+
var parts = winjsRe.exec(line);
|
|
1376
|
+
if (!parts) {
|
|
1377
|
+
return null;
|
|
1378
|
+
}
|
|
1379
|
+
return {
|
|
1380
|
+
file: parts[2],
|
|
1381
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1382
|
+
arguments: [],
|
|
1383
|
+
lineNumber: +parts[3],
|
|
1384
|
+
column: parts[4] ? +parts[4] : null
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|rsc|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
1388
|
+
var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
1389
|
+
function parseGecko(line) {
|
|
1390
|
+
var parts = geckoRe.exec(line);
|
|
1391
|
+
if (!parts) {
|
|
1392
|
+
return null;
|
|
1393
|
+
}
|
|
1394
|
+
var isEval = parts[3] && parts[3].indexOf(" > eval") > -1;
|
|
1395
|
+
var submatch = geckoEvalRe.exec(parts[3]);
|
|
1396
|
+
if (isEval && submatch != null) {
|
|
1397
|
+
parts[3] = submatch[1];
|
|
1398
|
+
parts[4] = submatch[2];
|
|
1399
|
+
parts[5] = null;
|
|
1400
|
+
}
|
|
1401
|
+
return {
|
|
1402
|
+
file: parts[3],
|
|
1403
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1404
|
+
arguments: parts[2] ? parts[2].split(",") : [],
|
|
1405
|
+
lineNumber: parts[4] ? +parts[4] : null,
|
|
1406
|
+
column: parts[5] ? +parts[5] : null
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
var javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
|
|
1410
|
+
function parseJSC(line) {
|
|
1411
|
+
var parts = javaScriptCoreRe.exec(line);
|
|
1412
|
+
if (!parts) {
|
|
1413
|
+
return null;
|
|
1414
|
+
}
|
|
1415
|
+
return {
|
|
1416
|
+
file: parts[3],
|
|
1417
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1418
|
+
arguments: [],
|
|
1419
|
+
lineNumber: +parts[4],
|
|
1420
|
+
column: parts[5] ? +parts[5] : null
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
var nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1424
|
+
function parseNode(line) {
|
|
1425
|
+
var parts = nodeRe.exec(line);
|
|
1426
|
+
if (!parts) {
|
|
1427
|
+
return null;
|
|
1428
|
+
}
|
|
1429
|
+
return {
|
|
1430
|
+
file: parts[2],
|
|
1431
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1432
|
+
arguments: [],
|
|
1433
|
+
lineNumber: +parts[3],
|
|
1434
|
+
column: parts[4] ? +parts[4] : null
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// src/build/analyze.ts
|
|
1129
1439
|
function throwExternalDependencyError({
|
|
1130
1440
|
errorId,
|
|
1131
1441
|
moduleName,
|
|
@@ -1149,6 +1459,110 @@ export const mastra = new Mastra({
|
|
|
1149
1459
|
})`
|
|
1150
1460
|
});
|
|
1151
1461
|
}
|
|
1462
|
+
function getPackageNameFromBundledModuleName(moduleName) {
|
|
1463
|
+
const chunks = moduleName.split("-");
|
|
1464
|
+
if (!chunks.length) {
|
|
1465
|
+
return moduleName;
|
|
1466
|
+
}
|
|
1467
|
+
if (chunks[0]?.startsWith("@")) {
|
|
1468
|
+
return chunks.slice(0, 2).join("/");
|
|
1469
|
+
}
|
|
1470
|
+
return chunks[0];
|
|
1471
|
+
}
|
|
1472
|
+
function validateError(err, file, {
|
|
1473
|
+
binaryMapData,
|
|
1474
|
+
workspaceMap
|
|
1475
|
+
}) {
|
|
1476
|
+
let moduleName = null;
|
|
1477
|
+
let errorConfig = null;
|
|
1478
|
+
if (err instanceof ValidationError) {
|
|
1479
|
+
const parsedStack = parse(err.stack);
|
|
1480
|
+
if (err.type === "TypeError") {
|
|
1481
|
+
const pkgNameRegex = /.*node_modules\/([^\/]+)\//;
|
|
1482
|
+
const stacktraceFrame = parsedStack.find((frame) => frame.file && pkgNameRegex.test(frame.file));
|
|
1483
|
+
if (stacktraceFrame) {
|
|
1484
|
+
const match = stacktraceFrame.file.match(pkgNameRegex);
|
|
1485
|
+
moduleName = match?.[1] ?? getPackageNameFromBundledModuleName(basename$1(file.name));
|
|
1486
|
+
} else {
|
|
1487
|
+
moduleName = getPackageNameFromBundledModuleName(basename$1(file.name));
|
|
1488
|
+
}
|
|
1489
|
+
errorConfig = {
|
|
1490
|
+
id: "DEPLOYER_ANALYZE_TYPE_ERROR",
|
|
1491
|
+
messagePrefix: `Mastra wasn't able to bundle "${moduleName}", might be an older commonJS module. Please add`
|
|
1492
|
+
};
|
|
1493
|
+
} else if (err.stack?.includes?.("[ERR_MODULE_NOT_FOUND]")) {
|
|
1494
|
+
moduleName = err.message.match(/Cannot find package '([^']+)'/)?.[1];
|
|
1495
|
+
const parentModuleName = getPackageNameFromBundledModuleName(basename$1(file.name));
|
|
1496
|
+
errorConfig = {
|
|
1497
|
+
id: "DEPLOYER_ANALYZE_MODULE_NOT_FOUND",
|
|
1498
|
+
messagePrefix: `Mastra wasn't able to build your project, We couldn't load "${moduleName}" from "${parentModuleName}". Make sure "${moduleName}" is installed or add`
|
|
1499
|
+
};
|
|
1500
|
+
if (moduleName === parentModuleName) {
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
if (err.message.includes("No native build was found")) {
|
|
1506
|
+
const pkgName = getPackageNameFromBundledModuleName(basename$1(file.name));
|
|
1507
|
+
moduleName = binaryMapData[file.fileName]?.[0] ?? pkgName;
|
|
1508
|
+
errorConfig = {
|
|
1509
|
+
id: "DEPLOYER_ANALYZE_MISSING_NATIVE_BUILD",
|
|
1510
|
+
messagePrefix: "We found a binary dependency in your bundle but we cannot bundle it yet. Please add"
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
if (moduleName && workspaceMap.has(moduleName)) {
|
|
1514
|
+
throw new MastraError({
|
|
1515
|
+
id: "DEPLOYER_ANALYZE_ERROR_IN_WORKSPACE",
|
|
1516
|
+
domain: ErrorDomain.DEPLOYER,
|
|
1517
|
+
category: ErrorCategory.USER,
|
|
1518
|
+
details: {
|
|
1519
|
+
// importFile: moduleName,
|
|
1520
|
+
packageName: moduleName
|
|
1521
|
+
},
|
|
1522
|
+
text: `We found an error in the ${moduleName} workspace package. Please find the offending package and fix the error.
|
|
1523
|
+
Error: ${err.stack}`
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
if (errorConfig && moduleName) {
|
|
1527
|
+
throwExternalDependencyError({
|
|
1528
|
+
errorId: errorConfig.id,
|
|
1529
|
+
moduleName,
|
|
1530
|
+
packageName: moduleName,
|
|
1531
|
+
messagePrefix: errorConfig.messagePrefix
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
async function validateFile(root, file, {
|
|
1536
|
+
binaryMapData,
|
|
1537
|
+
moduleResolveMapLocation,
|
|
1538
|
+
logger,
|
|
1539
|
+
workspaceMap
|
|
1540
|
+
}) {
|
|
1541
|
+
try {
|
|
1542
|
+
if (!file.isDynamicEntry && file.isEntry) {
|
|
1543
|
+
await validate(join(root, file.fileName), {
|
|
1544
|
+
moduleResolveMapLocation,
|
|
1545
|
+
injectESMShim: false
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
} catch (err) {
|
|
1549
|
+
let errorToHandle = err;
|
|
1550
|
+
if (err instanceof ValidationError && err.type === "ReferenceError" && (err.message.startsWith("__dirname") || err.message.startsWith("__filename"))) {
|
|
1551
|
+
try {
|
|
1552
|
+
await validate(join(root, file.fileName), {
|
|
1553
|
+
moduleResolveMapLocation,
|
|
1554
|
+
injectESMShim: true
|
|
1555
|
+
});
|
|
1556
|
+
errorToHandle = null;
|
|
1557
|
+
} catch (err2) {
|
|
1558
|
+
errorToHandle = err2;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
if (errorToHandle instanceof Error) {
|
|
1562
|
+
validateError(errorToHandle, file, { binaryMapData, workspaceMap });
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1152
1566
|
async function validateOutput({
|
|
1153
1567
|
output,
|
|
1154
1568
|
reverseVirtualReferenceMap,
|
|
@@ -1162,60 +1576,30 @@ async function validateOutput({
|
|
|
1162
1576
|
externalDependencies: /* @__PURE__ */ new Set(),
|
|
1163
1577
|
workspaceMap
|
|
1164
1578
|
};
|
|
1165
|
-
await writeFile(join(outputDir, "module-resolve-map.json"), JSON.stringify(usedExternals, null, 2));
|
|
1166
1579
|
for (const deps of Object.values(usedExternals)) {
|
|
1167
1580
|
for (const dep of Object.keys(deps)) {
|
|
1168
1581
|
result.externalDependencies.add(dep);
|
|
1169
1582
|
}
|
|
1170
1583
|
}
|
|
1584
|
+
let binaryMapData = {};
|
|
1585
|
+
if (existsSync(join(outputDir, "binary-map.json"))) {
|
|
1586
|
+
const binaryMap = await readFile(join(outputDir, "binary-map.json"), "utf-8");
|
|
1587
|
+
binaryMapData = JSON.parse(binaryMap);
|
|
1588
|
+
}
|
|
1171
1589
|
for (const file of output) {
|
|
1172
1590
|
if (file.type === "asset") {
|
|
1173
1591
|
continue;
|
|
1174
1592
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
|
|
1179
|
-
}
|
|
1180
|
-
if (!file.isDynamicEntry && file.isEntry) {
|
|
1181
|
-
await validate(join(projectRoot, file.fileName));
|
|
1182
|
-
}
|
|
1183
|
-
} catch (err) {
|
|
1184
|
-
if (err instanceof Error) {
|
|
1185
|
-
let moduleName = null;
|
|
1186
|
-
let errorConfig = null;
|
|
1187
|
-
if (err.message.includes("[ERR_MODULE_NOT_FOUND]")) {
|
|
1188
|
-
const moduleIdName = file.moduleIds.length >= 2 ? file.moduleIds[file.moduleIds.length - 2] : void 0;
|
|
1189
|
-
const fallbackName = file.name.split("/").pop();
|
|
1190
|
-
moduleName = moduleIdName ?? fallbackName;
|
|
1191
|
-
errorConfig = {
|
|
1192
|
-
id: "DEPLOYER_ANALYZE_MODULE_NOT_FOUND",
|
|
1193
|
-
messagePrefix: "Mastra wasn't able to build your project. Please add"
|
|
1194
|
-
};
|
|
1195
|
-
} else if (err.message.includes("Error: No native build was found for ")) {
|
|
1196
|
-
moduleName = findNativePackageModule(file.moduleIds);
|
|
1197
|
-
errorConfig = {
|
|
1198
|
-
id: "DEPLOYER_ANALYZE_MISSING_NATIVE_BUILD",
|
|
1199
|
-
messagePrefix: "We found a binary dependency in your bundle. Please add"
|
|
1200
|
-
};
|
|
1201
|
-
}
|
|
1202
|
-
if (moduleName && errorConfig) {
|
|
1203
|
-
const pkgInfo = await getPackageInfo(moduleName);
|
|
1204
|
-
const packageName = pkgInfo?.packageJson?.name;
|
|
1205
|
-
if (packageName) {
|
|
1206
|
-
throwExternalDependencyError({
|
|
1207
|
-
errorId: errorConfig.id,
|
|
1208
|
-
moduleName,
|
|
1209
|
-
packageName,
|
|
1210
|
-
messagePrefix: errorConfig.messagePrefix
|
|
1211
|
-
});
|
|
1212
|
-
} else {
|
|
1213
|
-
logger.debug(`Could not determine the module name for file ${file.fileName}`);
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
logger.debug(`Error while validating module ${file.fileName}: ${err.message}`);
|
|
1217
|
-
}
|
|
1593
|
+
logger.debug(`Validating if ${file.fileName} is a valid module.`);
|
|
1594
|
+
if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
|
|
1595
|
+
result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
|
|
1218
1596
|
}
|
|
1597
|
+
await validateFile(projectRoot, file, {
|
|
1598
|
+
binaryMapData,
|
|
1599
|
+
moduleResolveMapLocation: join(outputDir, "module-resolve-map.json"),
|
|
1600
|
+
logger,
|
|
1601
|
+
workspaceMap
|
|
1602
|
+
});
|
|
1219
1603
|
}
|
|
1220
1604
|
return result;
|
|
1221
1605
|
}
|
|
@@ -1247,17 +1631,26 @@ If you think your configuration is valid, please open an issue.`);
|
|
|
1247
1631
|
const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: mastraEntry });
|
|
1248
1632
|
let index = 0;
|
|
1249
1633
|
const depsToOptimize = /* @__PURE__ */ new Map();
|
|
1634
|
+
const { externals: customExternals = [] } = bundlerOptions || {};
|
|
1635
|
+
const allExternals = [...GLOBAL_EXTERNALS, ...customExternals];
|
|
1250
1636
|
logger.info("Analyzing dependencies...");
|
|
1637
|
+
const allUsedExternals = /* @__PURE__ */ new Set();
|
|
1251
1638
|
for (const entry of entries) {
|
|
1252
1639
|
const isVirtualFile = entry.includes("\n") || !existsSync(entry);
|
|
1253
1640
|
const analyzeResult = await analyzeEntry({ entry, isVirtualFile }, mastraEntry, {
|
|
1254
1641
|
logger,
|
|
1255
1642
|
sourcemapEnabled: bundlerOptions?.sourcemap ?? false,
|
|
1256
1643
|
workspaceMap,
|
|
1257
|
-
projectRoot
|
|
1644
|
+
projectRoot,
|
|
1645
|
+
shouldCheckTransitiveDependencies: isDev
|
|
1258
1646
|
});
|
|
1259
1647
|
await writeFile(join(outputDir, `entry-${index++}.mjs`), analyzeResult.output.code);
|
|
1260
1648
|
for (const [dep, metadata] of analyzeResult.dependencies.entries()) {
|
|
1649
|
+
const isPartOfExternals = allExternals.some((external) => isDependencyPartOfPackage(dep, external));
|
|
1650
|
+
if (isPartOfExternals) {
|
|
1651
|
+
allUsedExternals.add(dep);
|
|
1652
|
+
continue;
|
|
1653
|
+
}
|
|
1261
1654
|
if (depsToOptimize.has(dep)) {
|
|
1262
1655
|
const existingEntry = depsToOptimize.get(dep);
|
|
1263
1656
|
depsToOptimize.set(dep, {
|
|
@@ -1276,14 +1669,13 @@ If you think your configuration is valid, please open an issue.`);
|
|
|
1276
1669
|
}
|
|
1277
1670
|
}
|
|
1278
1671
|
}
|
|
1279
|
-
|
|
1672
|
+
const sortedDeps = Array.from(depsToOptimize.keys()).sort();
|
|
1280
1673
|
logger.info("Optimizing dependencies...");
|
|
1281
|
-
logger.debug(
|
|
1282
|
-
`${Array.from(depsToOptimize.keys()).map((key) => `- ${key}`).join("\n")}`
|
|
1283
|
-
);
|
|
1674
|
+
logger.debug(`${sortedDeps.map((key) => `- ${key}`).join("\n")}`);
|
|
1284
1675
|
const { output, fileNameToDependencyMap, usedExternals } = await bundleExternals(depsToOptimize, outputDir, {
|
|
1285
1676
|
bundlerOptions: {
|
|
1286
1677
|
...bundlerOptions,
|
|
1678
|
+
externals: allExternals,
|
|
1287
1679
|
enableEsmShim,
|
|
1288
1680
|
isDev
|
|
1289
1681
|
},
|
|
@@ -1302,9 +1694,12 @@ If you think your configuration is valid, please open an issue.`);
|
|
|
1302
1694
|
},
|
|
1303
1695
|
logger
|
|
1304
1696
|
);
|
|
1305
|
-
return
|
|
1697
|
+
return {
|
|
1698
|
+
...result,
|
|
1699
|
+
externalDependencies: /* @__PURE__ */ new Set([...result.externalDependencies, ...Array.from(allUsedExternals)])
|
|
1700
|
+
};
|
|
1306
1701
|
}
|
|
1307
1702
|
|
|
1308
|
-
export { aliasHono, analyzeBundle, esbuild, extractMastraOption, getBundlerOptions,
|
|
1309
|
-
//# sourceMappingURL=chunk-
|
|
1310
|
-
//# sourceMappingURL=chunk-
|
|
1703
|
+
export { aliasHono, analyzeBundle, esbuild, esmShim, extractMastraOption, getBundlerOptions, getPackageRootPath, getWorkspaceInformation, removeAllOptionsFromMastraExcept, removeDeployer2 as removeDeployer, subpathExternalsResolver, tsConfigPaths };
|
|
1704
|
+
//# sourceMappingURL=chunk-3KATYU33.js.map
|
|
1705
|
+
//# sourceMappingURL=chunk-3KATYU33.js.map
|