@mastra/deployer 1.54.0-alpha.0 → 1.54.0-alpha.2
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 +16 -0
- package/dist/analyze-C2q7jxbN.js +1308 -0
- package/dist/analyze-C2q7jxbN.js.map +1 -0
- package/dist/analyze-DhDZW9TS.cjs +1318 -0
- package/dist/analyze-DhDZW9TS.cjs.map +1 -0
- package/dist/arktype-aI7TBD0R-BsgjPZ4a.cjs +8 -0
- package/dist/arktype-aI7TBD0R-BsgjPZ4a.cjs.map +1 -0
- package/dist/arktype-aI7TBD0R-_UZl-wsH.js +8 -0
- package/dist/arktype-aI7TBD0R-_UZl-wsH.js.map +1 -0
- package/dist/build/analyze/constants.d.ts.map +1 -1
- package/dist/build/analyze.cjs +3 -12
- package/dist/build/analyze.js +2 -3
- package/dist/build/bundler.cjs +6 -24
- package/dist/build/bundler.js +2 -3
- package/dist/build/index.cjs +29 -101
- package/dist/build/index.js +7 -8
- package/dist/build-De4AZhfJ.cjs +908 -0
- package/dist/build-De4AZhfJ.cjs.map +1 -0
- package/dist/build-KCOeHd4N.js +834 -0
- package/dist/build-KCOeHd4N.js.map +1 -0
- package/dist/bundler/index.cjs +318 -13
- package/dist/bundler/index.cjs.map +1 -1
- package/dist/bundler/index.js +314 -2
- package/dist/bundler/index.js.map +1 -1
- package/dist/bundler-BqrDXofn.cjs +792 -0
- package/dist/bundler-BqrDXofn.cjs.map +1 -0
- package/dist/bundler-D86rFu2J.js +705 -0
- package/dist/bundler-D86rFu2J.js.map +1 -0
- package/dist/bundlerOptions-aFsEi86t.js +180 -0
- package/dist/bundlerOptions-aFsEi86t.js.map +1 -0
- package/dist/bundlerOptions-rBmtSyGe.cjs +194 -0
- package/dist/bundlerOptions-rBmtSyGe.cjs.map +1 -0
- package/dist/core-D0wEgdn3.cjs +790 -0
- package/dist/core-D0wEgdn3.cjs.map +1 -0
- package/dist/core-DF65PJXc.js +790 -0
- package/dist/core-DF65PJXc.js.map +1 -0
- package/dist/dist-BauTimif.js +532 -0
- package/dist/dist-BauTimif.js.map +1 -0
- package/dist/dist-Cv-mAEtr.cjs +532 -0
- package/dist/dist-Cv-mAEtr.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +2 -23
- package/dist/docs/references/docs-deployment-cloud-providers.md +1 -0
- package/dist/docs/references/docs-deployment-overview.md +1 -0
- package/dist/effect-QlVUlMFu-CwFnyS-g.cjs +14 -0
- package/dist/effect-QlVUlMFu-CwFnyS-g.cjs.map +1 -0
- package/dist/effect-QlVUlMFu-gyLQRCtQ.js +14 -0
- package/dist/effect-QlVUlMFu-gyLQRCtQ.js.map +1 -0
- package/dist/esm-BX-weMyC.js +4634 -0
- package/dist/esm-BX-weMyC.js.map +1 -0
- package/dist/esm-D81PZ_wJ.cjs +4634 -0
- package/dist/esm-D81PZ_wJ.cjs.map +1 -0
- package/dist/index-CLddUTqr-B5mOP6DC.cjs +145 -0
- package/dist/index-CLddUTqr-B5mOP6DC.cjs.map +1 -0
- package/dist/index-CLddUTqr-CkS6Y_hA.js +140 -0
- package/dist/index-CLddUTqr-CkS6Y_hA.js.map +1 -0
- package/dist/index.cjs +35 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -30
- package/dist/index.js.map +1 -1
- package/dist/rolldown-runtime-emK7D4bc.cjs +35 -0
- package/dist/server/index.cjs +3141 -3874
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3131 -3842
- package/dist/server/index.js.map +1 -1
- package/dist/server/types.d.ts +1 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/services/index.cjs +5 -20
- package/dist/services/index.js +2 -3
- package/dist/services-BxYMLS9-.cjs +430 -0
- package/dist/services-BxYMLS9-.cjs.map +1 -0
- package/dist/services-CLi56qqe.js +391 -0
- package/dist/services-CLi56qqe.js.map +1 -0
- package/dist/sury-CWZTCd75-B85M6878.js +14 -0
- package/dist/sury-CWZTCd75-B85M6878.js.map +1 -0
- package/dist/sury-CWZTCd75-DTj5HlK_.cjs +14 -0
- package/dist/sury-CWZTCd75-DTj5HlK_.cjs.map +1 -0
- package/dist/typebox-Dei93FPO-BeuT13_G.cjs +8 -0
- package/dist/typebox-Dei93FPO-BeuT13_G.cjs.map +1 -0
- package/dist/typebox-Dei93FPO-DovwMlVl.js +8 -0
- package/dist/typebox-Dei93FPO-DovwMlVl.js.map +1 -0
- package/dist/utils-FVOUvj-I.js +190 -0
- package/dist/utils-FVOUvj-I.js.map +1 -0
- package/dist/utils-O98BGdnP.cjs +267 -0
- package/dist/utils-O98BGdnP.cjs.map +1 -0
- package/dist/valibot--1zFm7rT-BqJHja5B.cjs +14 -0
- package/dist/valibot--1zFm7rT-BqJHja5B.cjs.map +1 -0
- package/dist/valibot--1zFm7rT-Y4Fhea0w.js +14 -0
- package/dist/valibot--1zFm7rT-Y4Fhea0w.js.map +1 -0
- package/dist/validator/custom-resolver.cjs +71 -73
- package/dist/validator/custom-resolver.cjs.map +1 -1
- package/dist/validator/custom-resolver.js +70 -71
- package/dist/validator/custom-resolver.js.map +1 -1
- package/dist/validator/loader.cjs +6 -7
- package/dist/validator/loader.cjs.map +1 -1
- package/dist/validator/loader.js +8 -4
- package/dist/validator/loader.js.map +1 -1
- package/dist/zod-Bwrt9trS-2JL6_UI_.cjs +23 -0
- package/dist/zod-Bwrt9trS-2JL6_UI_.cjs.map +1 -0
- package/dist/zod-Bwrt9trS-rVHICsmp.js +23 -0
- package/dist/zod-Bwrt9trS-rVHICsmp.js.map +1 -0
- package/package.json +7 -7
- package/dist/arktype-aI7TBD0R-K3QZAVE2.js +0 -8
- package/dist/arktype-aI7TBD0R-K3QZAVE2.js.map +0 -1
- package/dist/arktype-aI7TBD0R-WK5AZZMC.cjs +0 -10
- package/dist/arktype-aI7TBD0R-WK5AZZMC.cjs.map +0 -1
- package/dist/build/analyze.cjs.map +0 -1
- package/dist/build/analyze.js.map +0 -1
- package/dist/build/bundler.cjs.map +0 -1
- package/dist/build/bundler.js.map +0 -1
- package/dist/build/index.cjs.map +0 -1
- package/dist/build/index.js.map +0 -1
- package/dist/chunk-36AWZH7Z.cjs +0 -252
- package/dist/chunk-36AWZH7Z.cjs.map +0 -1
- package/dist/chunk-3XIMK24X.cjs +0 -765
- package/dist/chunk-3XIMK24X.cjs.map +0 -1
- package/dist/chunk-46M65MQG.cjs +0 -95
- package/dist/chunk-46M65MQG.cjs.map +0 -1
- package/dist/chunk-4ZNTNJ6T.js +0 -6
- package/dist/chunk-4ZNTNJ6T.js.map +0 -1
- package/dist/chunk-5PORNUPF.js +0 -739
- package/dist/chunk-5PORNUPF.js.map +0 -1
- package/dist/chunk-743HRNWT.cjs +0 -1546
- package/dist/chunk-743HRNWT.cjs.map +0 -1
- package/dist/chunk-AEQ7JHDB.cjs +0 -412
- package/dist/chunk-AEQ7JHDB.cjs.map +0 -1
- package/dist/chunk-E5SBYHQK.js +0 -244
- package/dist/chunk-E5SBYHQK.js.map +0 -1
- package/dist/chunk-FKKJQUGR.cjs +0 -497
- package/dist/chunk-FKKJQUGR.cjs.map +0 -1
- package/dist/chunk-FQHUOYYL.js +0 -1514
- package/dist/chunk-FQHUOYYL.js.map +0 -1
- package/dist/chunk-G7MIMGMX.js +0 -14
- package/dist/chunk-G7MIMGMX.js.map +0 -1
- package/dist/chunk-HZC3PTK2.cjs +0 -16
- package/dist/chunk-HZC3PTK2.cjs.map +0 -1
- package/dist/chunk-JZRFRUGM.cjs +0 -158
- package/dist/chunk-JZRFRUGM.cjs.map +0 -1
- package/dist/chunk-L45X3DJX.js +0 -385
- package/dist/chunk-L45X3DJX.js.map +0 -1
- package/dist/chunk-PC25XSK7.cjs +0 -8
- package/dist/chunk-PC25XSK7.cjs.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-Q7SFCCGT.cjs +0 -11
- package/dist/chunk-Q7SFCCGT.cjs.map +0 -1
- package/dist/chunk-T4UT2QX7.js +0 -3
- package/dist/chunk-T4UT2QX7.js.map +0 -1
- package/dist/chunk-UBIDJOJA.js +0 -93
- package/dist/chunk-UBIDJOJA.js.map +0 -1
- package/dist/chunk-V3EKV6QB.cjs +0 -162
- package/dist/chunk-V3EKV6QB.cjs.map +0 -1
- package/dist/chunk-WHD2QQ3N.js +0 -783
- package/dist/chunk-WHD2QQ3N.js.map +0 -1
- package/dist/chunk-WP65JQAT.js +0 -144
- package/dist/chunk-WP65JQAT.js.map +0 -1
- package/dist/chunk-YO5OFXPN.cjs +0 -819
- package/dist/chunk-YO5OFXPN.cjs.map +0 -1
- package/dist/chunk-YUBKHO52.js +0 -465
- package/dist/chunk-YUBKHO52.js.map +0 -1
- package/dist/chunk-YWMYXUHX.cjs +0 -4
- package/dist/chunk-YWMYXUHX.cjs.map +0 -1
- package/dist/chunk-ZKZOVNT4.js +0 -159
- package/dist/chunk-ZKZOVNT4.js.map +0 -1
- package/dist/core-XIDAXLRB.js +0 -11866
- package/dist/core-XIDAXLRB.js.map +0 -1
- package/dist/core-XJNQ4AY6.cjs +0 -12141
- package/dist/core-XJNQ4AY6.cjs.map +0 -1
- package/dist/default-u_dwuiYb-HGUAHA6N.cjs +0 -9
- package/dist/default-u_dwuiYb-HGUAHA6N.cjs.map +0 -1
- package/dist/default-u_dwuiYb-MVPTVDCE.js +0 -3
- package/dist/default-u_dwuiYb-MVPTVDCE.js.map +0 -1
- package/dist/dist-UEE5OLII.cjs +0 -521
- package/dist/dist-UEE5OLII.cjs.map +0 -1
- package/dist/dist-X75F2Q36.js +0 -515
- package/dist/dist-X75F2Q36.js.map +0 -1
- package/dist/effect-QlVUlMFu-QNLZLGWO.js +0 -15
- package/dist/effect-QlVUlMFu-QNLZLGWO.js.map +0 -1
- package/dist/effect-QlVUlMFu-XUD6EH23.cjs +0 -17
- package/dist/effect-QlVUlMFu-XUD6EH23.cjs.map +0 -1
- package/dist/esm-DFCHSIJZ.cjs +0 -1589
- package/dist/esm-DFCHSIJZ.cjs.map +0 -1
- package/dist/esm-PXGQ5WB4.js +0 -1542
- package/dist/esm-PXGQ5WB4.js.map +0 -1
- package/dist/services/index.cjs.map +0 -1
- package/dist/services/index.js.map +0 -1
- package/dist/sury-CWZTCd75-3KQQJ22C.cjs +0 -17
- package/dist/sury-CWZTCd75-3KQQJ22C.cjs.map +0 -1
- package/dist/sury-CWZTCd75-DZQHKAZF.js +0 -15
- package/dist/sury-CWZTCd75-DZQHKAZF.js.map +0 -1
- package/dist/typebox-Dei93FPO-GOYJ5OUT.js +0 -8
- package/dist/typebox-Dei93FPO-GOYJ5OUT.js.map +0 -1
- package/dist/typebox-Dei93FPO-M7J7E57W.cjs +0 -10
- package/dist/typebox-Dei93FPO-M7J7E57W.cjs.map +0 -1
- package/dist/valibot--1zFm7rT-NVM3G3TI.cjs +0 -17
- package/dist/valibot--1zFm7rT-NVM3G3TI.cjs.map +0 -1
- package/dist/valibot--1zFm7rT-ZVGQI7WV.js +0 -15
- package/dist/valibot--1zFm7rT-ZVGQI7WV.js.map +0 -1
- package/dist/valibot-D_HTw1Gn-UCPEGDL7.cjs +0 -45
- package/dist/valibot-D_HTw1Gn-UCPEGDL7.cjs.map +0 -1
- package/dist/valibot-D_HTw1Gn-XPR4F6VS.js +0 -43
- package/dist/valibot-D_HTw1Gn-XPR4F6VS.js.map +0 -1
- package/dist/zod-Bwrt9trS-GN7ZXBMN.js +0 -29
- package/dist/zod-Bwrt9trS-GN7ZXBMN.js.map +0 -1
- package/dist/zod-Bwrt9trS-OVKARV6W.cjs +0 -31
- package/dist/zod-Bwrt9trS-OVKARV6W.cjs.map +0 -1
- package/dist/zod-DSgpEGAE-E7YZZ7VC.js +0 -37
- package/dist/zod-DSgpEGAE-E7YZZ7VC.js.map +0 -1
- package/dist/zod-DSgpEGAE-UNQNGL2W.cjs +0 -39
- package/dist/zod-DSgpEGAE-UNQNGL2W.cjs.map +0 -1
package/dist/chunk-5PORNUPF.js
DELETED
|
@@ -1,739 +0,0 @@
|
|
|
1
|
-
import { getPackageName, isBareModuleSpecifier, isExternalProtocolImport, isDependencyPartOfPackage, slash, getNodeResolveOptions } from './chunk-WP65JQAT.js';
|
|
2
|
-
import path, { isAbsolute, join, normalize, dirname } from 'path';
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
4
|
-
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
|
|
5
|
-
import alias from '@rollup/plugin-alias';
|
|
6
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
7
|
-
import json from '@rollup/plugin-json';
|
|
8
|
-
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
9
|
-
import { rollup } from 'rollup';
|
|
10
|
-
import originalEsbuild from 'rollup-plugin-esbuild';
|
|
11
|
-
import originalEsmShim from '@rollup/plugin-esm-shim';
|
|
12
|
-
import { readFile } from 'fs/promises';
|
|
13
|
-
import fs, { statSync } from 'fs';
|
|
14
|
-
import { readJSON } from 'fs-extra/esm';
|
|
15
|
-
import { getPackageInfo } from 'local-pkg';
|
|
16
|
-
import { transformAsync, types } from '@babel/core';
|
|
17
|
-
import stripJsonComments from 'strip-json-comments';
|
|
18
|
-
import { createHandler } from 'typescript-paths';
|
|
19
|
-
|
|
20
|
-
function esbuild(options = {}) {
|
|
21
|
-
return originalEsbuild({
|
|
22
|
-
target: "node20",
|
|
23
|
-
platform: "node",
|
|
24
|
-
minify: false,
|
|
25
|
-
...options
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
var FilenameDeclarationRegex = /(?:const|let|var)\s+__filename/;
|
|
29
|
-
var DirnameDeclarationRegex = /(?:const|let|var)\s+__dirname/;
|
|
30
|
-
function esmShim() {
|
|
31
|
-
const original = originalEsmShim();
|
|
32
|
-
return {
|
|
33
|
-
name: "esm-shim",
|
|
34
|
-
renderChunk(code, chunk, opts, meta) {
|
|
35
|
-
const hasFilename = code.includes("__filename");
|
|
36
|
-
const hasDirname = code.includes("__dirname");
|
|
37
|
-
const userDeclaredFilename = hasFilename && FilenameDeclarationRegex.test(code);
|
|
38
|
-
const userDeclaredDirname = hasDirname && DirnameDeclarationRegex.test(code);
|
|
39
|
-
if (userDeclaredFilename || userDeclaredDirname) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
if (typeof original.renderChunk === "function") {
|
|
43
|
-
return original.renderChunk.call(this, code, chunk, opts, meta);
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/build/plugins/local-storage-detector.ts
|
|
51
|
-
var LOCAL_HOST_PATTERNS = [
|
|
52
|
-
{
|
|
53
|
-
pattern: /\bfile:\.{1,2}\/[^\s'"`]+\.(?:db|sqlite)\b/gi,
|
|
54
|
-
hint: "LibSQL/SQLite file path relative to the build host"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
pattern: /\b(?:postgres(?:ql)?|mysql|mongodb|redis|libsql):\/\/[^/\s'"`]*localhost\b/gi,
|
|
58
|
-
hint: "localhost in a connection string"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
pattern: /\b(?:postgres(?:ql)?|mysql|mongodb|redis|libsql):\/\/[^/\s'"`]*127\.0\.0\.1\b/g,
|
|
62
|
-
hint: "127.0.0.1 in a connection string"
|
|
63
|
-
}
|
|
64
|
-
];
|
|
65
|
-
var MASTRA_BUILD_DIR = /[\\/]\.mastra[\\/]\.build[\\/]/;
|
|
66
|
-
var PROCESS_ENV_DOT = /\bprocess\.env\.([A-Z_][A-Z0-9_]*)\b/g;
|
|
67
|
-
var PROCESS_ENV_BRACKET = /\bprocess\.env\[['"]([A-Z_][A-Z0-9_]*)['"]\]/g;
|
|
68
|
-
var LEGACY_LOCAL_PATHS_FILE = "preflight-local-paths.json";
|
|
69
|
-
var PREFLIGHT_METADATA_FILE = "preflight-metadata.json";
|
|
70
|
-
function collectEnvRefs(code) {
|
|
71
|
-
const refs = /* @__PURE__ */ new Set();
|
|
72
|
-
for (const m of code.matchAll(PROCESS_ENV_DOT)) refs.add(m[1]);
|
|
73
|
-
for (const m of code.matchAll(PROCESS_ENV_BRACKET)) refs.add(m[1]);
|
|
74
|
-
return refs;
|
|
75
|
-
}
|
|
76
|
-
function isAstNode(v) {
|
|
77
|
-
return typeof v === "object" && v !== null && typeof v.type === "string";
|
|
78
|
-
}
|
|
79
|
-
function walkAst(node, visit) {
|
|
80
|
-
visit(node);
|
|
81
|
-
for (const value of Object.values(node)) {
|
|
82
|
-
if (Array.isArray(value)) {
|
|
83
|
-
for (const item of value) {
|
|
84
|
-
if (isAstNode(item)) walkAst(item, visit);
|
|
85
|
-
}
|
|
86
|
-
} else if (isAstNode(value)) {
|
|
87
|
-
walkAst(value, visit);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function findFirstEnvRef(node) {
|
|
92
|
-
let found;
|
|
93
|
-
walkAst(node, (n) => {
|
|
94
|
-
if (found !== void 0) return;
|
|
95
|
-
if (n.type !== "MemberExpression") return;
|
|
96
|
-
const object = n.object;
|
|
97
|
-
if (!object || object.type !== "MemberExpression" || object.object?.type !== "Identifier" || object.object.name !== "process" || object.property?.type !== "Identifier" || object.property.name !== "env") {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const property = n.property;
|
|
101
|
-
if (property?.type === "Identifier" && !n.computed) {
|
|
102
|
-
found = property.name;
|
|
103
|
-
} else if (property?.type === "Literal" && typeof property.value === "string") {
|
|
104
|
-
found = property.value;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
return found;
|
|
108
|
-
}
|
|
109
|
-
function findGuardedValues(ast, values) {
|
|
110
|
-
const stringLiterals = [];
|
|
111
|
-
const guardedLiterals = /* @__PURE__ */ new Map();
|
|
112
|
-
walkAst(ast, (node) => {
|
|
113
|
-
if (node.type === "Literal" && typeof node.value === "string") {
|
|
114
|
-
stringLiterals.push(node);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (node.type === "LogicalExpression" && (node.operator === "||" || node.operator === "??")) {
|
|
118
|
-
const right = node.right;
|
|
119
|
-
if (right?.type === "Literal" && typeof right.value === "string") {
|
|
120
|
-
const envName = findFirstEnvRef(node.left);
|
|
121
|
-
if (envName) guardedLiterals.set(right, envName);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
const result = /* @__PURE__ */ new Map();
|
|
126
|
-
for (const value of values) {
|
|
127
|
-
const containing = stringLiterals.filter((lit) => lit.value.includes(value));
|
|
128
|
-
if (containing.length === 0) continue;
|
|
129
|
-
const guards = containing.map((lit) => guardedLiterals.get(lit));
|
|
130
|
-
const first = guards[0];
|
|
131
|
-
if (first !== void 0 && guards.every((g) => g === first)) {
|
|
132
|
-
result.set(value, first);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
function localStorageDetector(rootDir) {
|
|
138
|
-
const userModuleMatches = /* @__PURE__ */ new Map();
|
|
139
|
-
const userModuleEnvRefs = /* @__PURE__ */ new Map();
|
|
140
|
-
let normalizedRoot;
|
|
141
|
-
if (rootDir) {
|
|
142
|
-
let root = rootDir.replace(/\\/g, "/");
|
|
143
|
-
while (root.endsWith("/")) root = root.slice(0, -1);
|
|
144
|
-
normalizedRoot = root + "/";
|
|
145
|
-
}
|
|
146
|
-
return {
|
|
147
|
-
name: "mastra-local-storage-detector",
|
|
148
|
-
transform(_code, id) {
|
|
149
|
-
if (id.includes("node_modules")) return null;
|
|
150
|
-
if (MASTRA_BUILD_DIR.test(id)) return null;
|
|
151
|
-
if (normalizedRoot && !id.replace(/\\/g, "/").startsWith(normalizedRoot)) return null;
|
|
152
|
-
const refs = collectEnvRefs(_code);
|
|
153
|
-
if (refs.size > 0) {
|
|
154
|
-
userModuleEnvRefs.set(id, refs);
|
|
155
|
-
}
|
|
156
|
-
const matches = [];
|
|
157
|
-
for (const { pattern, hint } of LOCAL_HOST_PATTERNS) {
|
|
158
|
-
const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : pattern.flags + "g");
|
|
159
|
-
for (const m of _code.matchAll(re)) {
|
|
160
|
-
matches.push({ value: m[0], hint });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (matches.length > 0) {
|
|
164
|
-
try {
|
|
165
|
-
const ast = this.parse(_code);
|
|
166
|
-
const guarded = findGuardedValues(ast, new Set(matches.map((m) => m.value)));
|
|
167
|
-
for (const match of matches) {
|
|
168
|
-
const guardedBy = guarded.get(match.value);
|
|
169
|
-
if (guardedBy) match.guardedBy = guardedBy;
|
|
170
|
-
}
|
|
171
|
-
} catch {
|
|
172
|
-
}
|
|
173
|
-
userModuleMatches.set(id, matches);
|
|
174
|
-
}
|
|
175
|
-
return null;
|
|
176
|
-
},
|
|
177
|
-
generateBundle(_, bundle) {
|
|
178
|
-
const detections = [];
|
|
179
|
-
const seen = /* @__PURE__ */ new Set();
|
|
180
|
-
const userEnvRefs = /* @__PURE__ */ new Set();
|
|
181
|
-
for (const chunk of Object.values(bundle)) {
|
|
182
|
-
if (chunk.type !== "chunk") continue;
|
|
183
|
-
for (const [moduleId, moduleInfo] of Object.entries(chunk.modules)) {
|
|
184
|
-
if (moduleInfo.renderedLength === 0) continue;
|
|
185
|
-
for (const ref of userModuleEnvRefs.get(moduleId) ?? []) {
|
|
186
|
-
userEnvRefs.add(ref);
|
|
187
|
-
}
|
|
188
|
-
const matches = userModuleMatches.get(moduleId);
|
|
189
|
-
if (!matches) continue;
|
|
190
|
-
for (const { value, hint, guardedBy } of matches) {
|
|
191
|
-
const key = `${hint}::${value}`;
|
|
192
|
-
if (seen.has(key)) continue;
|
|
193
|
-
seen.add(key);
|
|
194
|
-
detections.push({ value, hint, module: moduleId, ...guardedBy ? { guardedBy } : {} });
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const metadata = {
|
|
199
|
-
version: 1,
|
|
200
|
-
localPaths: detections,
|
|
201
|
-
userEnvRefs: [...userEnvRefs].sort()
|
|
202
|
-
};
|
|
203
|
-
this.emitFile({
|
|
204
|
-
type: "asset",
|
|
205
|
-
fileName: PREFLIGHT_METADATA_FILE,
|
|
206
|
-
source: JSON.stringify(metadata)
|
|
207
|
-
});
|
|
208
|
-
this.emitFile({
|
|
209
|
-
type: "asset",
|
|
210
|
-
fileName: LEGACY_LOCAL_PATHS_FILE,
|
|
211
|
-
source: JSON.stringify(detections.map(({ value, hint, module }) => ({ value, hint, module })))
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
function toParentDirectoryUrl(parentPath) {
|
|
217
|
-
let fsPath = parentPath.startsWith("file://") ? fileURLToPath(parentPath) : parentPath;
|
|
218
|
-
try {
|
|
219
|
-
if (statSync(fsPath).isFile()) {
|
|
220
|
-
fsPath = dirname(fsPath);
|
|
221
|
-
}
|
|
222
|
-
} catch {
|
|
223
|
-
}
|
|
224
|
-
return pathToFileURL(fsPath).href;
|
|
225
|
-
}
|
|
226
|
-
async function getPackageRootPath(packageName, parentPath) {
|
|
227
|
-
let rootPath;
|
|
228
|
-
try {
|
|
229
|
-
let options = void 0;
|
|
230
|
-
if (parentPath) {
|
|
231
|
-
options = {
|
|
232
|
-
paths: [toParentDirectoryUrl(parentPath)]
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
const pkg = await getPackageInfo(packageName, options);
|
|
236
|
-
rootPath = pkg?.rootPath ?? null;
|
|
237
|
-
} catch {
|
|
238
|
-
rootPath = null;
|
|
239
|
-
}
|
|
240
|
-
return rootPath;
|
|
241
|
-
}
|
|
242
|
-
async function readPackageMetadata(rootPath, requestedPackageName) {
|
|
243
|
-
try {
|
|
244
|
-
const pkgJson = await readJSON(`${rootPath}/package.json`);
|
|
245
|
-
const version = pkgJson.version;
|
|
246
|
-
const actualPackageName = pkgJson.name;
|
|
247
|
-
const packageSpec = version && actualPackageName && requestedPackageName && requestedPackageName !== actualPackageName ? `npm:${actualPackageName}@${version}` : void 0;
|
|
248
|
-
return { rootPath, version, packageSpec };
|
|
249
|
-
} catch {
|
|
250
|
-
return { rootPath };
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
async function getPackageMetadata(packageName, parentPath) {
|
|
254
|
-
const requestedPackageName = getPackageName(packageName);
|
|
255
|
-
const packageNames = [...new Set([packageName, requestedPackageName].filter(Boolean))];
|
|
256
|
-
let firstRootPath = null;
|
|
257
|
-
for (const name of packageNames) {
|
|
258
|
-
const rootPath = await getPackageRootPath(name, parentPath);
|
|
259
|
-
firstRootPath ??= rootPath;
|
|
260
|
-
if (!rootPath) {
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
const metadata = await readPackageMetadata(rootPath, requestedPackageName ?? null);
|
|
264
|
-
if (metadata.version || metadata.packageSpec) {
|
|
265
|
-
return metadata;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return { rootPath: firstRootPath };
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// src/build/plugins/node-modules-extension-resolver.ts
|
|
272
|
-
async function getPackageJSON(pkgName, importer) {
|
|
273
|
-
const pkgRoot = await getPackageRootPath(pkgName, importer);
|
|
274
|
-
if (!pkgRoot) {
|
|
275
|
-
throw new Error(`Package ${pkgName} not found`);
|
|
276
|
-
}
|
|
277
|
-
const pkgJSON = JSON.parse(await readFile(join(pkgRoot, "package.json"), "utf-8"));
|
|
278
|
-
return pkgJSON;
|
|
279
|
-
}
|
|
280
|
-
function nodeModulesExtensionResolver() {
|
|
281
|
-
const nodeResolvePlugin = nodeResolve();
|
|
282
|
-
return {
|
|
283
|
-
name: "node-modules-extension-resolver",
|
|
284
|
-
async resolveId(id, importer, options) {
|
|
285
|
-
if (!importer || !isBareModuleSpecifier(id) || isExternalProtocolImport(id) || isAbsolute(id)) {
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
const parts = id.split("/");
|
|
289
|
-
const isScoped = id.startsWith("@");
|
|
290
|
-
if (isScoped && parts.length === 2 || !isScoped && parts.length === 1) {
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
const pkgName = getPackageName(id);
|
|
294
|
-
if (!pkgName) {
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
try {
|
|
298
|
-
const packageJSON = await getPackageJSON(pkgName, importer);
|
|
299
|
-
if (!!packageJSON.exports) {
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
const packageRoot = await getPackageRootPath(pkgName, importer);
|
|
303
|
-
const nodeResolved = await nodeResolvePlugin.resolveId?.handler?.call(this, id, importer, options);
|
|
304
|
-
if (!nodeResolved?.id) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
let filePath = nodeResolved.id;
|
|
308
|
-
if (nodeResolved.resolvedBy === "commonjs--resolver") {
|
|
309
|
-
filePath = filePath.substring(1).split("?")[0];
|
|
310
|
-
}
|
|
311
|
-
const resolvedImportPath = filePath.replace(packageRoot, pkgName);
|
|
312
|
-
return {
|
|
313
|
-
id: resolvedImportPath,
|
|
314
|
-
external: true
|
|
315
|
-
};
|
|
316
|
-
} catch (err) {
|
|
317
|
-
console.error(err);
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// src/build/plugins/protocol-external-resolver.ts
|
|
325
|
-
function protocolExternalResolver({ exclude = ["node:"] } = {}) {
|
|
326
|
-
return {
|
|
327
|
-
name: "protocol-external-resolver",
|
|
328
|
-
resolveId(id) {
|
|
329
|
-
if (!isExternalProtocolImport(id, exclude)) {
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
return {
|
|
333
|
-
id,
|
|
334
|
-
external: true
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
function removeDeployer() {
|
|
340
|
-
function removeDeployerFromObject(objectExpr, scope) {
|
|
341
|
-
const deployerProp = objectExpr.properties.find(
|
|
342
|
-
(prop) => types.isObjectProperty(prop) && types.isIdentifier(prop.key) && prop.key.name === "deployer"
|
|
343
|
-
);
|
|
344
|
-
if (deployerProp) {
|
|
345
|
-
objectExpr.properties = objectExpr.properties.filter((prop) => prop !== deployerProp);
|
|
346
|
-
if (types.isIdentifier(deployerProp.value)) {
|
|
347
|
-
const deployerBinding = scope.getBinding(deployerProp.value.name);
|
|
348
|
-
if (deployerBinding) {
|
|
349
|
-
deployerBinding.path?.parentPath?.remove();
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return deployerProp;
|
|
354
|
-
}
|
|
355
|
-
return {
|
|
356
|
-
name: "remove-deployer",
|
|
357
|
-
visitor: {
|
|
358
|
-
NewExpression(path2, state) {
|
|
359
|
-
const varDeclaratorPath = path2.findParent((path3) => types.isVariableDeclarator(path3.node));
|
|
360
|
-
if (!varDeclaratorPath) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
const parentNode = path2.parentPath.node;
|
|
364
|
-
if (!types.isVariableDeclarator(parentNode) || !types.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
if (!state.hasReplaced) {
|
|
368
|
-
state.hasReplaced = true;
|
|
369
|
-
const newMastraObj = types.cloneNode(path2.node);
|
|
370
|
-
if (types.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.length) {
|
|
371
|
-
const objectArg = newMastraObj.arguments[0];
|
|
372
|
-
let foundDeployer = false;
|
|
373
|
-
const directDeployer = removeDeployerFromObject(objectArg, state.file.scope);
|
|
374
|
-
if (directDeployer) {
|
|
375
|
-
foundDeployer = true;
|
|
376
|
-
}
|
|
377
|
-
for (const prop of objectArg.properties) {
|
|
378
|
-
if (types.isSpreadElement(prop) && types.isIdentifier(prop.argument)) {
|
|
379
|
-
const spreadBinding = state.file.scope.getBinding(prop.argument.name);
|
|
380
|
-
if (spreadBinding?.path && types.isVariableDeclarator(spreadBinding.path.node)) {
|
|
381
|
-
const init = spreadBinding.path.node.init;
|
|
382
|
-
if (types.isObjectExpression(init)) {
|
|
383
|
-
const spreadDeployer = removeDeployerFromObject(init, state.file.scope);
|
|
384
|
-
if (spreadDeployer) {
|
|
385
|
-
foundDeployer = true;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
if (foundDeployer) {
|
|
392
|
-
path2.replaceWith(newMastraObj);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// src/build/plugins/remove-deployer.ts
|
|
402
|
-
function removeDeployer2(mastraEntry, options) {
|
|
403
|
-
return {
|
|
404
|
-
name: "remove-deployer",
|
|
405
|
-
transform(code, id) {
|
|
406
|
-
if (id !== mastraEntry) {
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
return transformAsync(code, {
|
|
410
|
-
babelrc: false,
|
|
411
|
-
configFile: false,
|
|
412
|
-
filename: id,
|
|
413
|
-
plugins: [removeDeployer],
|
|
414
|
-
sourceMaps: options?.sourcemap
|
|
415
|
-
}).then((result) => ({
|
|
416
|
-
code: result.code,
|
|
417
|
-
map: result.map
|
|
418
|
-
}));
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// src/build/plugins/subpath-externals-resolver.ts
|
|
424
|
-
function subpathExternalsResolver(externals) {
|
|
425
|
-
return {
|
|
426
|
-
name: "subpath-externals-resolver",
|
|
427
|
-
resolveId(id) {
|
|
428
|
-
if (id.startsWith(".") || id.startsWith("/")) {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
const isPartOfExternals = externals.some((external) => isDependencyPartOfPackage(id, external));
|
|
432
|
-
if (isPartOfExternals) {
|
|
433
|
-
return {
|
|
434
|
-
id,
|
|
435
|
-
external: true
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
var PLUGIN_NAME = "tsconfig-paths";
|
|
442
|
-
var JS_IMPORT_SOURCE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
|
|
443
|
-
function hasPaths(tsConfigPath) {
|
|
444
|
-
try {
|
|
445
|
-
const content = fs.readFileSync(tsConfigPath, "utf8");
|
|
446
|
-
const config = JSON.parse(stripJsonComments(content));
|
|
447
|
-
return !!(config.compilerOptions?.paths && Object.keys(config.compilerOptions.paths).length > 0 || typeof config.extends === "string" && config.extends.length > 0 || Array.isArray(config.extends) && config.extends.length > 0);
|
|
448
|
-
} catch {
|
|
449
|
-
return false;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
|
|
453
|
-
const handlerCache = /* @__PURE__ */ new Map();
|
|
454
|
-
function resolveJsImportToSourceFile(moduleName) {
|
|
455
|
-
if (fs.existsSync(moduleName)) {
|
|
456
|
-
return moduleName;
|
|
457
|
-
}
|
|
458
|
-
const parsed = path.parse(moduleName);
|
|
459
|
-
if (parsed.ext !== ".js") {
|
|
460
|
-
return moduleName;
|
|
461
|
-
}
|
|
462
|
-
for (const extension of JS_IMPORT_SOURCE_EXTENSIONS) {
|
|
463
|
-
const candidate = path.join(parsed.dir, `${parsed.name}${extension}`);
|
|
464
|
-
if (fs.existsSync(candidate)) {
|
|
465
|
-
return candidate;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return moduleName;
|
|
469
|
-
}
|
|
470
|
-
function findTsConfigForFile(filePath) {
|
|
471
|
-
let currentDir = path.dirname(filePath);
|
|
472
|
-
const root = path.parse(currentDir).root;
|
|
473
|
-
while (currentDir !== root) {
|
|
474
|
-
const tsConfigPath2 = path.join(currentDir, "tsconfig.json");
|
|
475
|
-
if (fs.existsSync(tsConfigPath2)) {
|
|
476
|
-
if (hasPaths(tsConfigPath2)) {
|
|
477
|
-
return tsConfigPath2;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
const tsConfigBasePath = path.join(currentDir, "tsconfig.base.json");
|
|
481
|
-
if (fs.existsSync(tsConfigBasePath)) {
|
|
482
|
-
if (hasPaths(tsConfigBasePath)) {
|
|
483
|
-
return tsConfigBasePath;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
currentDir = path.dirname(currentDir);
|
|
487
|
-
}
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
function getHandlerForFile(filePath) {
|
|
491
|
-
if (tsConfigPath && typeof tsConfigPath === "string") {
|
|
492
|
-
if (!handlerCache.has(tsConfigPath)) {
|
|
493
|
-
handlerCache.set(
|
|
494
|
-
tsConfigPath,
|
|
495
|
-
createHandler({
|
|
496
|
-
log: () => {
|
|
497
|
-
},
|
|
498
|
-
tsConfigPath,
|
|
499
|
-
respectCoreModule,
|
|
500
|
-
falllback: (moduleName) => fs.existsSync(moduleName)
|
|
501
|
-
})
|
|
502
|
-
);
|
|
503
|
-
}
|
|
504
|
-
return handlerCache.get(tsConfigPath);
|
|
505
|
-
}
|
|
506
|
-
const configPath = findTsConfigForFile(filePath);
|
|
507
|
-
if (!configPath) {
|
|
508
|
-
return null;
|
|
509
|
-
}
|
|
510
|
-
if (!handlerCache.has(configPath)) {
|
|
511
|
-
handlerCache.set(
|
|
512
|
-
configPath,
|
|
513
|
-
createHandler({
|
|
514
|
-
log: () => {
|
|
515
|
-
},
|
|
516
|
-
tsConfigPath: configPath,
|
|
517
|
-
respectCoreModule,
|
|
518
|
-
falllback: (moduleName) => fs.existsSync(moduleName)
|
|
519
|
-
})
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
|
-
return handlerCache.get(configPath);
|
|
523
|
-
}
|
|
524
|
-
function resolveAlias(request, importer) {
|
|
525
|
-
const dynamicHandler = getHandlerForFile(importer);
|
|
526
|
-
if (!dynamicHandler) {
|
|
527
|
-
return null;
|
|
528
|
-
}
|
|
529
|
-
const resolved = dynamicHandler(request, normalize(importer));
|
|
530
|
-
return resolved;
|
|
531
|
-
}
|
|
532
|
-
return {
|
|
533
|
-
name: PLUGIN_NAME,
|
|
534
|
-
resolveId: {
|
|
535
|
-
order: "pre",
|
|
536
|
-
async handler(request, importer, options) {
|
|
537
|
-
if (!importer || request.startsWith("\0") || importer.charCodeAt(0) === 0) {
|
|
538
|
-
return null;
|
|
539
|
-
}
|
|
540
|
-
if (!path.isAbsolute(importer)) {
|
|
541
|
-
importer = path.resolve(process.cwd(), importer);
|
|
542
|
-
}
|
|
543
|
-
const moduleName = resolveAlias(request, importer);
|
|
544
|
-
if (!moduleName) {
|
|
545
|
-
const resolved2 = await this.resolve(request, importer, { skipSelf: true, ...options });
|
|
546
|
-
if (!resolved2) {
|
|
547
|
-
return null;
|
|
548
|
-
}
|
|
549
|
-
if (localResolve) {
|
|
550
|
-
const importerInfo = this.getModuleInfo(importer);
|
|
551
|
-
const importerPluginMeta = importerInfo?.meta?.[PLUGIN_NAME];
|
|
552
|
-
if (!request.startsWith("./") && !request.startsWith("../") && importerPluginMeta?.resolved) {
|
|
553
|
-
return {
|
|
554
|
-
...resolved2,
|
|
555
|
-
external: !request.startsWith("hono/") && request !== "hono"
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
return {
|
|
560
|
-
...resolved2,
|
|
561
|
-
meta: {
|
|
562
|
-
...resolved2.meta || {}
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
const resolvedModuleName = resolveJsImportToSourceFile(moduleName);
|
|
567
|
-
if (!path.extname(resolvedModuleName)) {
|
|
568
|
-
const resolved2 = await this.resolve(resolvedModuleName, importer, { skipSelf: true, ...options });
|
|
569
|
-
if (!resolved2) {
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
return {
|
|
573
|
-
...resolved2,
|
|
574
|
-
meta: {
|
|
575
|
-
...resolved2.meta,
|
|
576
|
-
[PLUGIN_NAME]: {
|
|
577
|
-
resolved: true
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
const resolved = await this.resolve(resolvedModuleName, importer, { skipSelf: true, ...options });
|
|
583
|
-
if (!resolved) {
|
|
584
|
-
return null;
|
|
585
|
-
}
|
|
586
|
-
return {
|
|
587
|
-
...resolved,
|
|
588
|
-
meta: {
|
|
589
|
-
...resolved.meta,
|
|
590
|
-
[PLUGIN_NAME]: {
|
|
591
|
-
resolved: true
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// src/build/bundler.ts
|
|
601
|
-
function mastraInternalAliasPlugin(entryFile) {
|
|
602
|
-
const normalizedEntryFile = slash(entryFile);
|
|
603
|
-
return alias({
|
|
604
|
-
entries: [
|
|
605
|
-
{
|
|
606
|
-
find: /^\#server$/,
|
|
607
|
-
replacement: slash(fileURLToPath(import.meta.resolve("@mastra/deployer/server")))
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
find: /^\@mastra\/server\/(.*)/,
|
|
611
|
-
replacement: `@mastra/server/$1`,
|
|
612
|
-
customResolver: (id) => {
|
|
613
|
-
if (id.startsWith("@mastra/server")) {
|
|
614
|
-
return {
|
|
615
|
-
id: fileURLToPath(import.meta.resolve(id))
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
},
|
|
620
|
-
{ find: /^\#mastra$/, replacement: normalizedEntryFile }
|
|
621
|
-
]
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
function mastraToolsAliasPlugin() {
|
|
625
|
-
return {
|
|
626
|
-
name: "tools-rewriter",
|
|
627
|
-
resolveId(id) {
|
|
628
|
-
if (id === "#tools") {
|
|
629
|
-
return {
|
|
630
|
-
id: "./tools.mjs",
|
|
631
|
-
external: true
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = { "process.env.NODE_ENV": JSON.stringify("production") }, {
|
|
638
|
-
sourcemap = false,
|
|
639
|
-
isDev = false,
|
|
640
|
-
projectRoot,
|
|
641
|
-
workspaceRoot = void 0,
|
|
642
|
-
enableEsmShim = true,
|
|
643
|
-
externalsPreset = false
|
|
644
|
-
}) {
|
|
645
|
-
const nodeResolvePlugin = nodeResolve(getNodeResolveOptions(platform));
|
|
646
|
-
const externalsCopy = new Set(analyzedBundleInfo.externalDependencies.keys());
|
|
647
|
-
const externals = externalsPreset ? [] : Array.from(externalsCopy);
|
|
648
|
-
return {
|
|
649
|
-
logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
|
|
650
|
-
treeshake: "smallest",
|
|
651
|
-
preserveSymlinks: true,
|
|
652
|
-
external: externals,
|
|
653
|
-
plugins: [
|
|
654
|
-
protocolExternalResolver(),
|
|
655
|
-
subpathExternalsResolver(externals),
|
|
656
|
-
{
|
|
657
|
-
name: "alias-optimized-deps",
|
|
658
|
-
resolveId(id) {
|
|
659
|
-
if (!analyzedBundleInfo.dependencies.has(id)) {
|
|
660
|
-
return null;
|
|
661
|
-
}
|
|
662
|
-
const filename = analyzedBundleInfo.dependencies.get(id);
|
|
663
|
-
const absolutePath = join(workspaceRoot || projectRoot, filename);
|
|
664
|
-
if (isDev) {
|
|
665
|
-
return {
|
|
666
|
-
id: process.platform === "win32" ? pathToFileURL(absolutePath).href : absolutePath,
|
|
667
|
-
external: true
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
return {
|
|
671
|
-
id: absolutePath,
|
|
672
|
-
external: false
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
},
|
|
676
|
-
mastraInternalAliasPlugin(entryFile),
|
|
677
|
-
tsConfigPaths(),
|
|
678
|
-
mastraToolsAliasPlugin(),
|
|
679
|
-
esbuild({
|
|
680
|
-
platform,
|
|
681
|
-
define: env
|
|
682
|
-
}),
|
|
683
|
-
optimizeLodashImports({
|
|
684
|
-
include: "**/*.{js,ts,mjs,cjs}"
|
|
685
|
-
}),
|
|
686
|
-
externalsPreset ? null : commonjs({
|
|
687
|
-
extensions: [".js", ".ts"],
|
|
688
|
-
transformMixedEsModules: true,
|
|
689
|
-
esmExternals(id) {
|
|
690
|
-
return externals.includes(id);
|
|
691
|
-
}
|
|
692
|
-
}),
|
|
693
|
-
enableEsmShim ? esmShim() : void 0,
|
|
694
|
-
externalsPreset ? nodeModulesExtensionResolver() : nodeResolvePlugin,
|
|
695
|
-
// for debugging
|
|
696
|
-
// {
|
|
697
|
-
// name: 'logger',
|
|
698
|
-
// //@ts-expect-error
|
|
699
|
-
// resolveId(id, ...args) {
|
|
700
|
-
// console.log({ id, args });
|
|
701
|
-
// },
|
|
702
|
-
// // @ts-expect-error
|
|
703
|
-
// transform(code, id) {
|
|
704
|
-
// if (code.includes('class Duplexify ')) {
|
|
705
|
-
// console.log({ duplex: id });
|
|
706
|
-
// }
|
|
707
|
-
// },
|
|
708
|
-
// },
|
|
709
|
-
json(),
|
|
710
|
-
localStorageDetector(workspaceRoot || projectRoot),
|
|
711
|
-
removeDeployer2(entryFile, { sourcemap }),
|
|
712
|
-
// treeshake unused imports
|
|
713
|
-
esbuild({
|
|
714
|
-
include: entryFile,
|
|
715
|
-
platform
|
|
716
|
-
})
|
|
717
|
-
].filter(Boolean)
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
async function createBundler(inputOptions, outputOptions) {
|
|
721
|
-
const bundler = await rollup(inputOptions);
|
|
722
|
-
return {
|
|
723
|
-
write: () => {
|
|
724
|
-
return bundler.write({
|
|
725
|
-
...outputOptions,
|
|
726
|
-
format: "esm",
|
|
727
|
-
entryFileNames: "[name].mjs",
|
|
728
|
-
chunkFileNames: "[name].mjs"
|
|
729
|
-
});
|
|
730
|
-
},
|
|
731
|
-
close: () => {
|
|
732
|
-
return bundler.close();
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
export { createBundler, esbuild, esmShim, getInputOptions, getPackageMetadata, getPackageRootPath, mastraInternalAliasPlugin, mastraToolsAliasPlugin, nodeModulesExtensionResolver, protocolExternalResolver, removeDeployer2 as removeDeployer, subpathExternalsResolver, tsConfigPaths };
|
|
738
|
-
//# sourceMappingURL=chunk-5PORNUPF.js.map
|
|
739
|
-
//# sourceMappingURL=chunk-5PORNUPF.js.map
|