@mastra/deployer 1.52.0-alpha.4 → 1.52.0-alpha.9
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 +48 -0
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/babel/check-config-export.d.ts +2 -2
- package/dist/build/babel/check-config-export.d.ts.map +1 -1
- package/dist/build/babel/detect-pino-transports.d.ts +2 -2
- package/dist/build/babel/detect-pino-transports.d.ts.map +1 -1
- package/dist/build/babel/remove-all-options-except.d.ts +2 -2
- package/dist/build/babel/remove-all-options-except.d.ts.map +1 -1
- package/dist/build/babel/remove-deployer.d.ts +6 -2
- package/dist/build/babel/remove-deployer.d.ts.map +1 -1
- package/dist/build/babel/remove-non-referenced-nodes.d.ts +2 -2
- package/dist/build/babel/remove-non-referenced-nodes.d.ts.map +1 -1
- package/dist/build/bundler.cjs +5 -5
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +22 -22
- package/dist/build/index.js +5 -5
- package/dist/build/plugins/remove-all-except.d.ts.map +1 -1
- package/dist/build/plugins/remove-deployer.d.ts.map +1 -1
- package/dist/build/plugins/remove-unused-references.d.ts.map +1 -1
- package/dist/bundler/index.cjs +3 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-UFIOPABI.cjs → chunk-4XMRN3U4.cjs} +41 -54
- package/dist/chunk-4XMRN3U4.cjs.map +1 -0
- package/dist/{chunk-PLCERTF6.js → chunk-72CHYUGH.js} +6 -6
- package/dist/{chunk-PLCERTF6.js.map → chunk-72CHYUGH.js.map} +1 -1
- package/dist/{chunk-X2ZJLEWO.cjs → chunk-7CT7DAME.cjs} +13 -24
- package/dist/chunk-7CT7DAME.cjs.map +1 -0
- package/dist/{chunk-UY7KZXD2.js → chunk-CBK2CAL4.js} +7 -7
- package/dist/chunk-CBK2CAL4.js.map +1 -0
- package/dist/{chunk-VKAFARW6.cjs → chunk-FKKJQUGR.cjs} +4 -4
- package/dist/{chunk-VKAFARW6.cjs.map → chunk-FKKJQUGR.cjs.map} +1 -1
- package/dist/{chunk-SZ3KU5RT.cjs → chunk-GPKHP7J7.cjs} +12 -12
- package/dist/{chunk-SZ3KU5RT.cjs.map → chunk-GPKHP7J7.cjs.map} +1 -1
- package/dist/{chunk-S32IJ4F6.js → chunk-H6J5QQ45.js} +5 -5
- package/dist/{chunk-S32IJ4F6.js.map → chunk-H6J5QQ45.js.map} +1 -1
- package/dist/{chunk-5K7ECKKW.js → chunk-HPYZGYQL.js} +13 -25
- package/dist/chunk-HPYZGYQL.js.map +1 -0
- package/dist/{chunk-JTWXTX2D.js → chunk-PXUWQC3X.js} +37 -51
- package/dist/chunk-PXUWQC3X.js.map +1 -0
- package/dist/{chunk-2SUO6N5G.cjs → chunk-QGBVR3DR.cjs} +14 -14
- package/dist/{chunk-2SUO6N5G.cjs.map → chunk-QGBVR3DR.cjs.map} +1 -1
- package/dist/{chunk-7BDGRATY.cjs → chunk-XOP6IB66.cjs} +24 -24
- package/dist/chunk-XOP6IB66.cjs.map +1 -0
- package/dist/{chunk-ZL66GDLP.js → chunk-YUBKHO52.js} +2 -2
- package/dist/{chunk-ZL66GDLP.js.map → chunk-YUBKHO52.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +5 -5
- package/dist/docs/references/docs-deployment-mastra-server.md +35 -0
- package/dist/docs/references/docs-deployment-monorepo.md +2 -0
- package/dist/docs/references/docs-deployment-overview.md +6 -0
- package/dist/index.cjs +11 -11
- package/dist/index.js +4 -4
- package/dist/server/index.cjs +9 -2
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +9 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.js +1 -1
- package/package.json +12 -14
- package/dist/chunk-5K7ECKKW.js.map +0 -1
- package/dist/chunk-7BDGRATY.cjs.map +0 -1
- package/dist/chunk-JTWXTX2D.js.map +0 -1
- package/dist/chunk-UFIOPABI.cjs.map +0 -1
- package/dist/chunk-UY7KZXD2.js.map +0 -1
- package/dist/chunk-X2ZJLEWO.cjs.map +0 -1
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import { tsConfigPaths, esbuild } from './chunk-
|
|
1
|
+
import { tsConfigPaths, esbuild } from './chunk-HPYZGYQL.js';
|
|
2
2
|
import { pathToFileURL } from 'url';
|
|
3
3
|
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
|
|
4
4
|
import commonjs from '@rollup/plugin-commonjs';
|
|
5
5
|
import json from '@rollup/plugin-json';
|
|
6
6
|
import { rollup } from 'rollup';
|
|
7
7
|
import * as babel from '@babel/core';
|
|
8
|
-
import babel__default from '@babel/core';
|
|
9
8
|
|
|
10
9
|
function removeAllOptionsFromMastraExcept(result, option, logger) {
|
|
11
|
-
const t =
|
|
10
|
+
const t = babel.types;
|
|
12
11
|
return {
|
|
13
12
|
name: "remove-all-except-" + option + "-config",
|
|
14
13
|
visitor: {
|
|
15
14
|
ExportNamedDeclaration: {
|
|
16
|
-
// remove all exports
|
|
15
|
+
// remove all exports, but keep the underlying declarations — the
|
|
16
|
+
// extracted option may reference them (e.g. `export const deployer = ...`
|
|
17
|
+
// used as `new Mastra({ deployer })`). Unreferenced declarations are
|
|
18
|
+
// dropped by the cleanup pass afterwards.
|
|
17
19
|
exit(path) {
|
|
18
|
-
path.
|
|
20
|
+
if (path.node.declaration) {
|
|
21
|
+
const [declaration] = path.replaceWith(path.node.declaration);
|
|
22
|
+
declaration.skip();
|
|
23
|
+
} else {
|
|
24
|
+
path.remove();
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
27
|
},
|
|
21
28
|
NewExpression(path, state) {
|
|
@@ -89,32 +96,21 @@ function removeAllOptionsFromMastraExceptPlugin(mastraEntry, name, result, optio
|
|
|
89
96
|
if (id !== mastraEntry) {
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
(err, result2) => {
|
|
103
|
-
if (err) {
|
|
104
|
-
return reject(err);
|
|
105
|
-
}
|
|
106
|
-
resolve({
|
|
107
|
-
code: result2.code,
|
|
108
|
-
map: result2.map
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
});
|
|
99
|
+
return babel.transformAsync(code, {
|
|
100
|
+
babelrc: false,
|
|
101
|
+
configFile: false,
|
|
102
|
+
filename: id,
|
|
103
|
+
plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],
|
|
104
|
+
sourceMaps: options?.sourcemap
|
|
105
|
+
}).then((result2) => ({
|
|
106
|
+
code: result2.code,
|
|
107
|
+
map: result2.map
|
|
108
|
+
}));
|
|
113
109
|
}
|
|
114
110
|
};
|
|
115
111
|
}
|
|
116
112
|
function removeNonReferencedNodes() {
|
|
117
|
-
const t =
|
|
113
|
+
const t = babel.types;
|
|
118
114
|
return {
|
|
119
115
|
name: "remove-non-referenced-nodes",
|
|
120
116
|
visitor: {
|
|
@@ -162,29 +158,19 @@ function removeNonReferencedNodes() {
|
|
|
162
158
|
}
|
|
163
159
|
|
|
164
160
|
// src/build/plugins/remove-unused-references.ts
|
|
165
|
-
function recursiveRemoveNonReferencedNodes(code) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
babelrc: false,
|
|
171
|
-
configFile: false,
|
|
172
|
-
plugins: [removeNonReferencedNodes()]
|
|
173
|
-
},
|
|
174
|
-
(err, result) => {
|
|
175
|
-
if (err) {
|
|
176
|
-
return reject(err);
|
|
177
|
-
}
|
|
178
|
-
if (result && result.code !== code) {
|
|
179
|
-
return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
|
|
180
|
-
}
|
|
181
|
-
resolve({
|
|
182
|
-
code: result.code,
|
|
183
|
-
map: result.map
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
);
|
|
161
|
+
async function recursiveRemoveNonReferencedNodes(code) {
|
|
162
|
+
const result = await babel.transformAsync(code, {
|
|
163
|
+
babelrc: false,
|
|
164
|
+
configFile: false,
|
|
165
|
+
plugins: [removeNonReferencedNodes]
|
|
187
166
|
});
|
|
167
|
+
if (result && result.code !== code) {
|
|
168
|
+
return recursiveRemoveNonReferencedNodes(result.code);
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
code: result.code,
|
|
172
|
+
map: result.map
|
|
173
|
+
};
|
|
188
174
|
}
|
|
189
175
|
|
|
190
176
|
// src/build/shared/extract-mastra-option.ts
|
|
@@ -256,5 +242,5 @@ async function getBundlerOptions(entryFile, outputDir, logger) {
|
|
|
256
242
|
}
|
|
257
243
|
|
|
258
244
|
export { extractMastraOption, getBundlerOptions };
|
|
259
|
-
//# sourceMappingURL=chunk-
|
|
260
|
-
//# sourceMappingURL=chunk-
|
|
245
|
+
//# sourceMappingURL=chunk-PXUWQC3X.js.map
|
|
246
|
+
//# sourceMappingURL=chunk-PXUWQC3X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build/babel/remove-all-options-except.ts","../src/build/plugins/remove-all-except.ts","../src/build/babel/remove-non-referenced-nodes.ts","../src/build/plugins/remove-unused-references.ts","../src/build/shared/extract-mastra-option.ts","../src/build/bundlerOptions.ts"],"names":["path","babel2","result","babel3","babel4"],"mappings":";;;;;;;;AAKO,SAAS,gCAAA,CACd,MAAA,EACA,MAAA,EACA,MAAA,EACoB;AACpB,EAAA,MAAM,CAAA,GAAU,KAAA,CAAA,KAAA;AAEhB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,uBAAuB,MAAA,GAAS,SAAA;AAAA,IACtC,OAAA,EAAS;AAAA,MACP,sBAAA,EAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,QAKtB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AA,EACA,SAAA,EACA,SAAA,EACA,MAAA,EAIQ;AACR,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,eAAA,EAAiB;AAAA,GACnB;AAEA,EAAA,MAAM,UAAU,MAAM,0BAAA,CAA2B,IAAA,EAAM,SAAA,EAAW,QAAQ,MAAM,CAAA;AAEhF,EAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,KAAA,CAAM;AAAA,IACjC,GAAA,EAAK,SAAA;AAAA,IACL,MAAA,EAAQ,IAAA;AAAA,IACR,cAAA,EAAgB;AAAA,GACjB,CAAA;AAED,EAAA,IAAI,OAAO,eAAA,EAAiB;AAC1B,IAAA,MAAM,UAAA,GAAa,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,IAAI,CAAA,WAAA,CAAA;AAEvC,IAAA,OAAO;AAAA,MACL,YAAA,EAAc,MAAA;AAAA,MACd,SAAA,EAAW,MAAM,OAAO,aAAA,CAAc,UAAU,CAAA,CAAE,IAAA,CAAA,CAAM,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,IAAI,CAAoB;AAAA,KAC9F;AAAA,EACF;AAEA,EAAA,OAAO,IAAA;AACT;;;AC9EA,eAAsB,iBAAA,CACpB,SAAA,EACA,SAAA,EACA,MAAA,EACmC;AACnC,EAAA,MAAM,SAAS,MAAM,mBAAA,CAAoB,SAAA,EAAW,SAAA,EAAW,WAAW,MAAM,CAAA;AAEhF,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,OAAO,SAAA,EAAU;AAC1B","file":"chunk-PXUWQC3X.js","sourcesContent":["import * as babel from '@babel/core';\nimport type { NodePath, types } from '@babel/core';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\n\nexport function removeAllOptionsFromMastraExcept(\n result: { hasCustomConfig: boolean },\n option: keyof MastraConfig,\n logger?: IMastraLogger,\n): babel.PluginObject {\n const t = babel.types;\n\n return {\n name: 'remove-all-except-' + option + '-config',\n visitor: {\n ExportNamedDeclaration: {\n // remove all exports, but keep the underlying declarations — the\n // extracted option may reference them (e.g. `export const deployer = ...`\n // used as `new Mastra({ deployer })`). Unreferenced declarations are\n // dropped by the cleanup pass afterwards.\n exit(path) {\n if (path.node.declaration) {\n const [declaration] = path.replaceWith(path.node.declaration);\n // Already traversed — don't requeue, or the NewExpression visitor\n // would append the extracted export a second time.\n declaration.skip();\n } else {\n path.remove();\n }\n },\n },\n\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n let mastraArgs = t.objectExpression([]);\n if (t.isObjectExpression(path.node.arguments[0])) {\n mastraArgs = path.node.arguments[0];\n }\n\n // Find the config property, skipping SpreadElement nodes\n let configProperty = mastraArgs.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option,\n );\n let configValue: types.Expression = t.objectExpression([]);\n\n const programPath = path.scope.getProgramParent().path as NodePath<types.Program> | undefined;\n if (!programPath) {\n return;\n }\n\n if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {\n result.hasCustomConfig = true;\n configValue = configProperty.value;\n\n if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {\n const configBinding = state.file.scope.getBinding(option)!;\n\n if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {\n const id = path.scope.generateUidIdentifier(option);\n\n configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init!));\n configValue = id;\n }\n }\n }\n\n // add the deployer export\n const exportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), configValue)]),\n [],\n );\n\n programPath.node.body.push(exportDeclaration);\n },\n\n Program: {\n exit(path) {\n // Add a fallback export if no mastra configuration was found\n const hasExport = path.node.body.some(\n node => node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration',\n );\n\n if (!hasExport) {\n if (logger) {\n logger.warn('Mastra config could not be extracted', {\n option,\n details:\n 'Please make sure your entry file looks like this:\\nexport const mastra = new Mastra({\\n <option>: <value>\\n})',\n });\n }\n\n const fallbackExportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),\n [],\n );\n path.node.body.push(fallbackExportDeclaration);\n }\n },\n },\n },\n } satisfies babel.PluginObject;\n}\n","import * as babel from '@babel/core';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport type { Plugin, SourceMapInput } from 'rollup';\nimport { removeAllOptionsFromMastraExcept } from '../babel/remove-all-options-except';\n\nexport function removeAllOptionsFromMastraExceptPlugin(\n mastraEntry: string,\n name: keyof MastraConfig,\n result: { hasCustomConfig: boolean },\n options?: { sourcemap?: boolean; logger?: IMastraLogger },\n): Plugin {\n return {\n name: `remove-${name}`,\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return babel\n .transformAsync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],\n sourceMaps: options?.sourcemap,\n })\n .then(result => ({\n code: result!.code!,\n map: result!.map! as SourceMapInput,\n }));\n },\n } satisfies Plugin;\n}\n","import * as babel from '@babel/core';\n\nexport function removeNonReferencedNodes() {\n const t = babel.types;\n\n return {\n name: 'remove-non-referenced-nodes',\n visitor: {\n Program(path) {\n // Get the scope information\n const scope = path.scope;\n\n // Filter body to keep only referenced nodes\n const currentBody = path.get('body');\n const filteredBody = currentBody.filter(childPath => {\n if (childPath.isExportDeclaration()) {\n return true;\n }\n\n // For variable declarations, check if any declared variables are referenced\n if (childPath.isVariableDeclaration()) {\n return childPath.node.declarations.some(decl => {\n if (!t.isIdentifier(decl.id)) {\n return false;\n }\n\n const name = decl.id.name;\n const binding = scope.getBinding(name);\n // Keep if it has references or is exported\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // For function/class declarations, check if they're referenced\n if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {\n if (!t.isIdentifier(childPath.node.id)) {\n return false;\n }\n\n const name = childPath.node.id.name;\n const binding = scope.getBinding(name);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n }\n\n // For imports, check if any imported items are referenced\n if (childPath.isImportDeclaration()) {\n return childPath.node.specifiers.some(specifier => {\n const importedName = specifier.local.name;\n const binding = scope.getBinding(importedName);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // Default to keeping other node types\n return false;\n });\n\n // Replace the program body with filtered nodes\n path.set(\n 'body',\n filteredBody.map(p => p.node),\n );\n },\n },\n } as babel.PluginObject;\n}\n","import * as babel from '@babel/core';\nimport { removeNonReferencedNodes } from '../babel/remove-non-referenced-nodes';\n\nexport async function recursiveRemoveNonReferencedNodes(code: string): Promise<{ code: string; map: any }> {\n const result = await babel.transformAsync(code, {\n babelrc: false,\n configFile: false,\n plugins: [removeNonReferencedNodes],\n });\n\n // keep looping until the code is not changed\n if (result && result.code! !== code) {\n return recursiveRemoveNonReferencedNodes(result!.code!);\n }\n\n return {\n code: result!.code!,\n map: result!.map!,\n };\n}\n","import { pathToFileURL } from 'node:url';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport { rollup } from 'rollup';\nimport type { RollupOutput } from 'rollup';\nimport { esbuild } from '../plugins/esbuild';\nimport { removeAllOptionsFromMastraExceptPlugin } from '../plugins/remove-all-except';\nimport { recursiveRemoveNonReferencedNodes } from '../plugins/remove-unused-references';\nimport { tsConfigPaths } from '../plugins/tsconfig-paths';\n\nexport function extractMastraOptionBundler(\n name: keyof MastraConfig,\n entryFile: string,\n result: {\n hasCustomConfig: boolean;\n },\n logger?: IMastraLogger,\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n [`${name}-config`]: entryFile,\n },\n treeshake: 'smallest',\n plugins: [\n tsConfigPaths(),\n // transpile typescript to something we understand\n esbuild(),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n json(),\n removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),\n // let esbuild remove all unused imports\n esbuild(),\n {\n name: 'cleanup',\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return recursiveRemoveNonReferencedNodes(code);\n },\n },\n // let esbuild remove it once more\n esbuild(),\n ],\n });\n}\n\nexport async function extractMastraOption<T extends keyof MastraConfig>(\n name: T,\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{\n bundleOutput: RollupOutput;\n getConfig: () => Promise<MastraConfig[T]>;\n} | null> {\n const result = {\n hasCustomConfig: false,\n };\n\n const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);\n\n const output = await bundler.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n });\n\n if (result.hasCustomConfig) {\n const configPath = `${outputDir}/${name}-config.mjs`;\n\n return {\n bundleOutput: output,\n getConfig: () => import(pathToFileURL(configPath).href).then(m => m[name] as MastraConfig[T]),\n };\n }\n\n return null;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getBundlerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('bundler', entryFile, result);\n}\n\nexport async function getBundlerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['bundler'] | null> {\n const result = await extractMastraOption('bundler', entryFile, outputDir, logger);\n\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunk4XMRN3U4_cjs = require('./chunk-4XMRN3U4.cjs');
|
|
4
|
+
var chunkXOP6IB66_cjs = require('./chunk-XOP6IB66.cjs');
|
|
5
|
+
var chunk7CT7DAME_cjs = require('./chunk-7CT7DAME.cjs');
|
|
6
|
+
var chunkFKKJQUGR_cjs = require('./chunk-FKKJQUGR.cjs');
|
|
7
7
|
var chunkJZRFRUGM_cjs = require('./chunk-JZRFRUGM.cjs');
|
|
8
8
|
var child_process = require('child_process');
|
|
9
9
|
var fs = require('fs');
|
|
@@ -89,7 +89,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
createBundler(inputOptions, outputOptions) {
|
|
92
|
-
return
|
|
92
|
+
return chunk7CT7DAME_cjs.createBundler(inputOptions, outputOptions);
|
|
93
93
|
}
|
|
94
94
|
async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
|
|
95
95
|
const defaultBundlerOptions = {
|
|
@@ -99,7 +99,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
99
99
|
[IS_DEFAULT]: true
|
|
100
100
|
};
|
|
101
101
|
try {
|
|
102
|
-
const bundlerOptions = await
|
|
102
|
+
const bundlerOptions = await chunk4XMRN3U4_cjs.getBundlerOptions(mastraEntryFile, outputDirectory);
|
|
103
103
|
return bundlerOptions ?? defaultBundlerOptions;
|
|
104
104
|
} catch (error) {
|
|
105
105
|
this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
|
|
@@ -107,7 +107,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
107
107
|
return defaultBundlerOptions;
|
|
108
108
|
}
|
|
109
109
|
async analyze(entry, mastraFile, outputDirectory) {
|
|
110
|
-
return await
|
|
110
|
+
return await chunkXOP6IB66_cjs.analyzeBundle(
|
|
111
111
|
[].concat(entry),
|
|
112
112
|
mastraFile,
|
|
113
113
|
{
|
|
@@ -119,7 +119,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
async installDependencies(outputDirectory, rootDir = process.cwd()) {
|
|
122
|
-
const deps = new
|
|
122
|
+
const deps = new chunkFKKJQUGR_cjs.DepsService(rootDir);
|
|
123
123
|
deps.__setLogger(this.logger);
|
|
124
124
|
await deps.install({ dir: path.join(outputDirectory, this.outputDir) });
|
|
125
125
|
}
|
|
@@ -178,10 +178,10 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, { enableSourcemap, enableEsmShim, externals }) {
|
|
181
|
-
const { workspaceRoot } = await
|
|
181
|
+
const { workspaceRoot } = await chunkXOP6IB66_cjs.getWorkspaceInformation({ mastraEntryFile });
|
|
182
182
|
const closestPkgJson = pkg__namespace.up({ cwd: path.dirname(mastraEntryFile) });
|
|
183
183
|
const projectRoot = closestPkgJson ? path.dirname(closestPkgJson) : process.cwd();
|
|
184
|
-
const inputOptions = await
|
|
184
|
+
const inputOptions = await chunk7CT7DAME_cjs.getInputOptions(
|
|
185
185
|
mastraEntryFile,
|
|
186
186
|
analyzedBundleInfo,
|
|
187
187
|
this.platform,
|
|
@@ -226,7 +226,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
226
226
|
});
|
|
227
227
|
for (const path$1 of expandedPaths) {
|
|
228
228
|
if (await fsExtra__default.default.pathExists(path$1)) {
|
|
229
|
-
const fileService = new
|
|
229
|
+
const fileService = new chunkFKKJQUGR_cjs.FileService();
|
|
230
230
|
const entryFile = fileService.getFirstExistingFile([
|
|
231
231
|
path.join(path$1, "index.ts"),
|
|
232
232
|
path.join(path$1, "index.js"),
|
|
@@ -263,7 +263,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
263
263
|
let analyzedBundleInfo;
|
|
264
264
|
try {
|
|
265
265
|
const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);
|
|
266
|
-
analyzedBundleInfo = await
|
|
266
|
+
analyzedBundleInfo = await chunkXOP6IB66_cjs.analyzeBundle(
|
|
267
267
|
[serverFile, ...Object.values(resolvedToolsPaths)],
|
|
268
268
|
mastraEntryFile,
|
|
269
269
|
{
|
|
@@ -380,5 +380,5 @@ export const tools = [${toolsExports.join(", ")}]`
|
|
|
380
380
|
|
|
381
381
|
exports.Bundler = Bundler;
|
|
382
382
|
exports.IS_DEFAULT = IS_DEFAULT;
|
|
383
|
-
//# sourceMappingURL=chunk-
|
|
384
|
-
//# sourceMappingURL=chunk-
|
|
383
|
+
//# sourceMappingURL=chunk-QGBVR3DR.cjs.map
|
|
384
|
+
//# sourceMappingURL=chunk-QGBVR3DR.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bundler/index.ts"],"names":["MastraBundler","emptyDir","ensureDir","join","writeFile","createBundler","getBundlerOptions","analyzeBundle","DepsService","fsExtra","execSync","rm","stat","copy","getWorkspaceInformation","pkg","dirname","getInputOptions","existsSync","virtual","slash","posix","glob","path","FileService","error","MastraError","ErrorDomain","ErrorCategory","isBareModuleSpecifier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAM,UAAA,0BAAoB,YAAY;AAEtC,IAAe,OAAA,GAAf,cAA+BA,qBAAA,CAAc;AAAA,EACxC,gBAAA,GAAmB,QAAA;AAAA,EACnB,SAAA,GAAY,QAAA;AAAA,EACZ,QAAA,GAA4B,MAAA;AAAA,EAE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B,eAAA,EAAiB,WAAW,CAAA;AAC3D,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,8BAA8B,CAAA;AAE/C,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,yCAAyC,CAAA;AAC1D,MAAA,MAAM,KAAK,mBAAA,CAAoBb,SAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,SAAS,CAAC,CAAA;AACpE,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,mCAAmC,CAAA;AAAA,IACtD,SAASsB,OAAA,EAAO;AACd,MAAA,MAAM,UAAUA,OAAA,YAAiB,KAAA,GAAQA,OAAA,CAAM,OAAA,GAAU,OAAOA,OAAK,CAAA;AACrE,MAAA,MAAM,IAAIC,iBAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,sCAAA;AAAA,UACJ,IAAA,EAAM,uCAAuC,OAAO,CAAA,CAAA;AAAA,UACpD,QAAQC,iBAAA,CAAY,QAAA;AAAA,UACpB,UAAUC,mBAAA,CAAc;AAAA,SAC1B;AAAA,QACAH;AAAA,OACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,IAAA,CAAK,UAAA,EAAoB,gBAAA,EAA0B,UAAA,EAAkD;AACzG,IAAA,MAAM,iBAAA,GAAoB,MAAM,IAAA,CAAK,qBAAA,CAAsB,UAAU,CAAA;AACrE,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,CAAE,MAAA;AACnD,IAAA,IAAI,cAAc,CAAA,EAAG;AACnB,MAAA,IAAA,CAAK,OAAO,IAAA,CAAK,aAAA,EAAe,EAAE,KAAA,EAAO,aAAa,CAAA;AAAA,IACxD;AAAA,EACF;AACF","file":"chunk-2SUO6N5G.cjs","sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { rm, stat, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { MastraBundler } from '@mastra/core/bundler';\nimport { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport type { Config } from '@mastra/core/mastra';\nimport virtual from '@rollup/plugin-virtual';\nimport * as pkg from 'empathic/package';\nimport fsExtra, { copy, ensureDir, emptyDir } from 'fs-extra/esm';\nimport type { InputOptions, OutputOptions } from 'rollup';\nimport { glob } from 'tinyglobby';\nimport { analyzeBundle } from '../build/analyze';\nimport { createBundler as createBundlerUtil, getInputOptions } from '../build/bundler';\nimport { getBundlerOptions } from '../build/bundlerOptions';\nimport type { BundlerOptions, ExternalDependencyInfo } from '../build/types';\nimport type { BundlerPlatform } from '../build/utils';\nimport { isBareModuleSpecifier, slash } from '../build/utils';\nimport { DepsService } from '../services/deps';\nimport { FileService } from '../services/fs';\nimport { getWorkspaceInformation } from './workspaceDependencies';\n\nexport type { BundlerOptions } from '../build/types';\nexport type { BundlerPlatform } from '../build/utils';\n\nexport const IS_DEFAULT = Symbol('IS_DEFAULT');\n\nexport abstract class Bundler extends MastraBundler {\n protected analyzeOutputDir = '.build';\n protected outputDir = 'output';\n protected platform: BundlerPlatform = 'node';\n\n constructor(name: string, component: 'BUNDLER' | 'DEPLOYER' = 'BUNDLER') {\n super({ name, component });\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n // Clean up the output directory first\n await emptyDir(outputDirectory);\n\n await ensureDir(join(outputDirectory, this.analyzeOutputDir));\n await ensureDir(join(outputDirectory, this.outputDir));\n }\n\n async writePackageJson(\n outputDirectory: string,\n dependencies: Map<string, string | ExternalDependencyInfo>,\n resolutions?: Record<string, string>,\n ) {\n this.logger.debug(\"Writing project's package.json\");\n\n await ensureDir(outputDirectory);\n const pkgPath = join(outputDirectory, 'package.json');\n\n const dependenciesMap = new Map();\n for (const [key, value] of dependencies.entries()) {\n const dependencyValue = typeof value === 'string' ? value : (value.packageSpec ?? value.version ?? 'latest');\n if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, dependencyValue);\n } else {\n // For non-scoped packages, take only the first part before any slash\n const pkgName = key.split('/')[0] || key;\n dependenciesMap.set(pkgName, dependencyValue);\n }\n }\n\n await writeFile(\n pkgPath,\n JSON.stringify(\n {\n name: 'server',\n version: '1.0.0',\n private: true,\n type: 'module',\n main: 'index.mjs',\n scripts: {\n start: 'node ./index.mjs',\n },\n dependencies: Object.fromEntries(dependenciesMap.entries()),\n ...(Object.keys(resolutions ?? {}).length > 0 && { resolutions }),\n },\n null,\n 2,\n ),\n );\n }\n\n protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & { dir: string }) {\n return createBundlerUtil(inputOptions, outputOptions);\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const defaultBundlerOptions: Config['bundler'] = {\n externals: [],\n sourcemap: false,\n transpilePackages: [],\n [IS_DEFAULT]: true,\n } as const;\n\n try {\n const bundlerOptions = await getBundlerOptions(mastraEntryFile, outputDirectory);\n\n return bundlerOptions ?? defaultBundlerOptions;\n } catch (error) {\n this.logger.debug('Failed to get bundler options, sourcemap will be disabled', { error });\n }\n\n return defaultBundlerOptions;\n }\n\n protected async analyze(entry: string | string[], mastraFile: string, outputDirectory: string) {\n return await analyzeBundle(\n ([] as string[]).concat(entry),\n mastraFile,\n {\n outputDir: join(outputDirectory, this.analyzeOutputDir),\n projectRoot: outputDirectory,\n platform: this.platform,\n },\n this.logger,\n );\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n }\n\n /**\n * Generate a package-lock.json for the output directory so that deploy targets\n * can use `npm ci` instead of `npm install`, skipping version resolution entirely.\n * This is a lockfile-only operation — no packages are downloaded.\n *\n * Temporarily moves node_modules out of the way because pnpm's symlink-based\n * layout confuses npm's arborist, then restores it afterwards so that\n * `mastra start` (or wrangler) can still resolve dependencies at runtime.\n */\n private async generateNpmLockfile(outputDir: string): Promise<void> {\n const nodeModules = join(outputDir, 'node_modules');\n const nodeModulesTmp = join(outputDir, 'node_modules.__tmp');\n let movedNodeModules = false;\n try {\n // Move node_modules aside — pnpm's symlink layout confuses npm's arborist\n if (await fsExtra.pathExists(nodeModules)) {\n await fsExtra.move(nodeModules, nodeModulesTmp, { overwrite: true });\n movedNodeModules = true;\n }\n execSync('npm install --package-lock-only --force', {\n cwd: outputDir,\n stdio: 'pipe',\n timeout: 60_000,\n });\n } catch {\n this.logger.warn('Failed to generate package-lock.json — deploy will fall back to npm install');\n } finally {\n // Restore node_modules so runtime resolution works\n if (movedNodeModules) {\n await rm(nodeModules, { recursive: true, force: true });\n await fsExtra.move(nodeModulesTmp, nodeModules, { overwrite: true });\n }\n }\n }\n\n protected async copyPublic(mastraDir: string, outputDirectory: string) {\n const publicDir = join(mastraDir, 'public');\n\n try {\n await stat(publicDir);\n } catch {\n return;\n }\n\n await copy(publicDir, join(outputDirectory, this.outputDir));\n }\n\n protected async copyDOTNPMRC({\n rootDir = process.cwd(),\n outputDirectory,\n }: {\n rootDir?: string;\n outputDirectory: string;\n }) {\n const sourceDotNpmRcPath = join(rootDir, '.npmrc');\n const targetDotNpmRcPath = join(outputDirectory, this.outputDir, '.npmrc');\n\n try {\n await stat(sourceDotNpmRcPath);\n await copy(sourceDotNpmRcPath, targetDotNpmRcPath);\n } catch {\n return;\n }\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n { enableSourcemap, enableEsmShim, externals }: BundlerOptions,\n ) {\n const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });\n const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });\n const projectRoot = closestPkgJson ? dirname(closestPkgJson) : process.cwd();\n\n const inputOptions: InputOptions = await getInputOptions(\n mastraEntryFile,\n analyzedBundleInfo,\n this.platform,\n {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n },\n { sourcemap: enableSourcemap, workspaceRoot, projectRoot, enableEsmShim, externalsPreset: externals === true },\n );\n const isVirtual = serverFile.includes('\\n') || !existsSync(serverFile);\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n\n if (isVirtual) {\n inputOptions.input = { index: '#entry', ...toolsInputOptions };\n\n if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.unshift(virtual({ '#entry': serverFile }));\n } else {\n inputOptions.plugins = [virtual({ '#entry': serverFile })];\n }\n } else {\n inputOptions.input = { index: serverFile, ...toolsInputOptions };\n }\n\n return inputOptions;\n }\n\n getAllToolPaths(mastraDir: string, toolsPaths: (string | string[])[] = []): (string | string[])[] {\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedMastraDir = slash(mastraDir);\n\n // Prepare default tools paths with glob patterns\n const defaultToolsPath = posix.join(normalizedMastraDir, 'tools/**/*.{js,ts}');\n const defaultToolsIgnorePaths = [\n `!${posix.join(normalizedMastraDir, 'tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'tools/**/__tests__/**')}`,\n ];\n\n // Combine default path with ignore patterns\n const defaultPaths = [defaultToolsPath, ...defaultToolsIgnorePaths];\n\n // If no tools paths provided, use only the default paths\n if (toolsPaths.length === 0) {\n return [defaultPaths];\n }\n\n // If tools paths are provided, add the default paths to ensure standard tools are always included\n return [...toolsPaths, defaultPaths];\n }\n\n async listToolsInputOptions(toolsPaths: (string | string[])[]) {\n const inputs: Record<string, string> = {};\n\n for (const toolPath of toolsPaths) {\n const expandedPaths = await glob(toolPath, {\n absolute: true,\n expandDirectories: false,\n });\n\n for (const path of expandedPaths) {\n if (await fsExtra.pathExists(path)) {\n const fileService = new FileService();\n const entryFile = fileService.getFirstExistingFile([\n join(path, 'index.ts'),\n join(path, 'index.js'),\n path, // if path itself is a file\n ]);\n\n // if it doesn't exist or is a dir skip it. using a dir as a tool will crash the process\n if (!entryFile || (await stat(entryFile)).isDirectory()) {\n this.logger.warn('No entry file found, skipping', { path });\n continue;\n }\n\n const uniqueToolID = crypto.randomUUID();\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedEntryFile = entryFile.replaceAll('\\\\', '/');\n inputs[`tools/${uniqueToolID}`] = normalizedEntryFile;\n } else {\n this.logger.warn('Tool path does not exist, skipping', { path });\n }\n }\n }\n\n return inputs;\n }\n\n protected async _bundle(\n serverFile: string,\n mastraEntryFile: string,\n {\n projectRoot,\n outputDirectory,\n enableEsmShim = true,\n }: {\n projectRoot: string;\n outputDirectory: string;\n enableEsmShim?: boolean;\n },\n toolsPaths: (string | string[])[] = [],\n bundleLocation: string = join(outputDirectory, this.outputDir),\n ): Promise<void> {\n const analyzeDir = join(outputDirectory, this.analyzeOutputDir);\n\n const bundlerOptions = await this.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n const internalBundlerOptions: BundlerOptions = {\n enableSourcemap: !!bundlerOptions.sourcemap,\n externals: bundlerOptions.externals ?? [],\n enableEsmShim,\n dynamicPackages: bundlerOptions.dynamicPackages,\n };\n\n let analyzedBundleInfo;\n try {\n const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);\n analyzedBundleInfo = await analyzeBundle(\n [serverFile, ...Object.values(resolvedToolsPaths)],\n mastraEntryFile,\n {\n outputDir: analyzeDir,\n projectRoot,\n platform: this.platform,\n bundlerOptions: internalBundlerOptions,\n },\n this.logger,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n if (error instanceof MastraError) {\n throw error;\n }\n\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_ANALYZE_FAILED',\n text: `Failed to analyze Mastra application: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n\n const dependenciesToInstall = new Map<string, ExternalDependencyInfo>();\n for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {\n if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) {\n continue;\n }\n\n dependenciesToInstall.set(dep, depInfo);\n }\n\n try {\n await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall);\n\n this.logger.info('Bundling Mastra application');\n\n const inputOptions: InputOptions = await this.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n internalBundlerOptions,\n );\n\n const bundler = await this.createBundler(\n {\n ...inputOptions,\n logLevel: inputOptions.logLevel === 'silent' ? 'warn' : inputOptions.logLevel,\n onwarn: warning => {\n if (warning.code === 'CIRCULAR_DEPENDENCY') {\n if (warning.ids?.[0]?.includes('node_modules')) {\n return;\n }\n\n this.logger.warn('Circular dependency found', {\n dependency: warning.message.replace('Circular dependency: ', ''),\n });\n }\n },\n },\n {\n dir: bundleLocation,\n manualChunks: {\n mastra: ['#mastra'],\n },\n sourcemap: internalBundlerOptions.enableSourcemap,\n },\n );\n\n await bundler.write();\n const toolImports: string[] = [];\n const toolsExports: string[] = [];\n Array.from(Object.keys(inputOptions.input || {}))\n .filter(key => key.startsWith('tools/'))\n .forEach((key, index) => {\n const toolExport = `tool${index}`;\n toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);\n toolsExports.push(toolExport);\n });\n\n await writeFile(\n join(bundleLocation, 'tools.mjs'),\n `${toolImports.join('\\n')}\n\nexport const tools = [${toolsExports.join(', ')}]`,\n );\n this.logger.info('Bundling Mastra done');\n\n this.logger.info('Copying public files');\n await this.copyPublic(dirname(mastraEntryFile), outputDirectory);\n this.logger.info('Done copying public files');\n\n this.logger.info('Copying .npmrc file');\n await this.copyDOTNPMRC({ outputDirectory, rootDir: projectRoot });\n\n this.logger.info('Done copying .npmrc file');\n\n this.logger.info('Installing dependencies');\n await this.installDependencies(outputDirectory, projectRoot);\n this.logger.info('Done installing dependencies');\n\n this.logger.info('Generating package-lock.json for deploy');\n await this.generateNpmLockfile(join(outputDirectory, this.outputDir));\n this.logger.info('Done generating package-lock.json');\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED',\n text: `Failed during bundler bundle stage: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n }\n\n async lint(_entryFile: string, _outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n const toolsLength = Object.keys(toolsInputOptions).length;\n if (toolsLength > 0) {\n this.logger.info('Found tools', { count: toolsLength });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/bundler/index.ts"],"names":["MastraBundler","emptyDir","ensureDir","join","writeFile","createBundler","getBundlerOptions","analyzeBundle","DepsService","fsExtra","execSync","rm","stat","copy","getWorkspaceInformation","pkg","dirname","getInputOptions","existsSync","virtual","slash","posix","glob","path","FileService","error","MastraError","ErrorDomain","ErrorCategory","isBareModuleSpecifier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAM,UAAA,0BAAoB,YAAY;AAEtC,IAAe,OAAA,GAAf,cAA+BA,qBAAA,CAAc;AAAA,EACxC,gBAAA,GAAmB,QAAA;AAAA,EACnB,SAAA,GAAY,QAAA;AAAA,EACZ,QAAA,GAA4B,MAAA;AAAA,EAEtC,WAAA,CAAY,IAAA,EAAc,SAAA,GAAoC,SAAA,EAAW;AACvE,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,SAAA,EAAW,CAAA;AAAA,EAC3B;AAAA,EAEA,MAAM,QAAQ,eAAA,EAAwC;AAEpD,IAAA,MAAMC,iBAAS,eAAe,CAAA;AAE9B,IAAA,MAAMC,iBAAA,CAAUC,SAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,gBAAgB,CAAC,CAAA;AAC5D,IAAA,MAAMD,iBAAA,CAAUC,SAAA,CAAK,eAAA,EAAi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A,YAAiB,KAAA,GAAQA,OAAA,CAAM,OAAA,GAAU,OAAOA,OAAK,CAAA;AACrE,MAAA,MAAM,IAAIC,iBAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,sCAAA;AAAA,UACJ,IAAA,EAAM,uCAAuC,OAAO,CAAA,CAAA;AAAA,UACpD,QAAQC,iBAAA,CAAY,QAAA;AAAA,UACpB,UAAUC,mBAAA,CAAc;AAAA,SAC1B;AAAA,QACAH;AAAA,OACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,IAAA,CAAK,UAAA,EAAoB,gBAAA,EAA0B,UAAA,EAAkD;AACzG,IAAA,MAAM,iBAAA,GAAoB,MAAM,IAAA,CAAK,qBAAA,CAAsB,UAAU,CAAA;AACrE,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,CAAE,MAAA;AACnD,IAAA,IAAI,cAAc,CAAA,EAAG;AACnB,MAAA,IAAA,CAAK,OAAO,IAAA,CAAK,aAAA,EAAe,EAAE,KAAA,EAAO,aAAa,CAAA;AAAA,IACxD;AAAA,EACF;AACF","file":"chunk-QGBVR3DR.cjs","sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { rm, stat, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { MastraBundler } from '@mastra/core/bundler';\nimport { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport type { Config } from '@mastra/core/mastra';\nimport virtual from '@rollup/plugin-virtual';\nimport * as pkg from 'empathic/package';\nimport fsExtra, { copy, ensureDir, emptyDir } from 'fs-extra/esm';\nimport type { InputOptions, OutputOptions } from 'rollup';\nimport { glob } from 'tinyglobby';\nimport { analyzeBundle } from '../build/analyze';\nimport { createBundler as createBundlerUtil, getInputOptions } from '../build/bundler';\nimport { getBundlerOptions } from '../build/bundlerOptions';\nimport type { BundlerOptions, ExternalDependencyInfo } from '../build/types';\nimport type { BundlerPlatform } from '../build/utils';\nimport { isBareModuleSpecifier, slash } from '../build/utils';\nimport { DepsService } from '../services/deps';\nimport { FileService } from '../services/fs';\nimport { getWorkspaceInformation } from './workspaceDependencies';\n\nexport type { BundlerOptions } from '../build/types';\nexport type { BundlerPlatform } from '../build/utils';\n\nexport const IS_DEFAULT = Symbol('IS_DEFAULT');\n\nexport abstract class Bundler extends MastraBundler {\n protected analyzeOutputDir = '.build';\n protected outputDir = 'output';\n protected platform: BundlerPlatform = 'node';\n\n constructor(name: string, component: 'BUNDLER' | 'DEPLOYER' = 'BUNDLER') {\n super({ name, component });\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n // Clean up the output directory first\n await emptyDir(outputDirectory);\n\n await ensureDir(join(outputDirectory, this.analyzeOutputDir));\n await ensureDir(join(outputDirectory, this.outputDir));\n }\n\n async writePackageJson(\n outputDirectory: string,\n dependencies: Map<string, string | ExternalDependencyInfo>,\n resolutions?: Record<string, string>,\n ) {\n this.logger.debug(\"Writing project's package.json\");\n\n await ensureDir(outputDirectory);\n const pkgPath = join(outputDirectory, 'package.json');\n\n const dependenciesMap = new Map();\n for (const [key, value] of dependencies.entries()) {\n const dependencyValue = typeof value === 'string' ? value : (value.packageSpec ?? value.version ?? 'latest');\n if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, dependencyValue);\n } else {\n // For non-scoped packages, take only the first part before any slash\n const pkgName = key.split('/')[0] || key;\n dependenciesMap.set(pkgName, dependencyValue);\n }\n }\n\n await writeFile(\n pkgPath,\n JSON.stringify(\n {\n name: 'server',\n version: '1.0.0',\n private: true,\n type: 'module',\n main: 'index.mjs',\n scripts: {\n start: 'node ./index.mjs',\n },\n dependencies: Object.fromEntries(dependenciesMap.entries()),\n ...(Object.keys(resolutions ?? {}).length > 0 && { resolutions }),\n },\n null,\n 2,\n ),\n );\n }\n\n protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & { dir: string }) {\n return createBundlerUtil(inputOptions, outputOptions);\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const defaultBundlerOptions: Config['bundler'] = {\n externals: [],\n sourcemap: false,\n transpilePackages: [],\n [IS_DEFAULT]: true,\n } as const;\n\n try {\n const bundlerOptions = await getBundlerOptions(mastraEntryFile, outputDirectory);\n\n return bundlerOptions ?? defaultBundlerOptions;\n } catch (error) {\n this.logger.debug('Failed to get bundler options, sourcemap will be disabled', { error });\n }\n\n return defaultBundlerOptions;\n }\n\n protected async analyze(entry: string | string[], mastraFile: string, outputDirectory: string) {\n return await analyzeBundle(\n ([] as string[]).concat(entry),\n mastraFile,\n {\n outputDir: join(outputDirectory, this.analyzeOutputDir),\n projectRoot: outputDirectory,\n platform: this.platform,\n },\n this.logger,\n );\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n }\n\n /**\n * Generate a package-lock.json for the output directory so that deploy targets\n * can use `npm ci` instead of `npm install`, skipping version resolution entirely.\n * This is a lockfile-only operation — no packages are downloaded.\n *\n * Temporarily moves node_modules out of the way because pnpm's symlink-based\n * layout confuses npm's arborist, then restores it afterwards so that\n * `mastra start` (or wrangler) can still resolve dependencies at runtime.\n */\n private async generateNpmLockfile(outputDir: string): Promise<void> {\n const nodeModules = join(outputDir, 'node_modules');\n const nodeModulesTmp = join(outputDir, 'node_modules.__tmp');\n let movedNodeModules = false;\n try {\n // Move node_modules aside — pnpm's symlink layout confuses npm's arborist\n if (await fsExtra.pathExists(nodeModules)) {\n await fsExtra.move(nodeModules, nodeModulesTmp, { overwrite: true });\n movedNodeModules = true;\n }\n execSync('npm install --package-lock-only --force', {\n cwd: outputDir,\n stdio: 'pipe',\n timeout: 60_000,\n });\n } catch {\n this.logger.warn('Failed to generate package-lock.json — deploy will fall back to npm install');\n } finally {\n // Restore node_modules so runtime resolution works\n if (movedNodeModules) {\n await rm(nodeModules, { recursive: true, force: true });\n await fsExtra.move(nodeModulesTmp, nodeModules, { overwrite: true });\n }\n }\n }\n\n protected async copyPublic(mastraDir: string, outputDirectory: string) {\n const publicDir = join(mastraDir, 'public');\n\n try {\n await stat(publicDir);\n } catch {\n return;\n }\n\n await copy(publicDir, join(outputDirectory, this.outputDir));\n }\n\n protected async copyDOTNPMRC({\n rootDir = process.cwd(),\n outputDirectory,\n }: {\n rootDir?: string;\n outputDirectory: string;\n }) {\n const sourceDotNpmRcPath = join(rootDir, '.npmrc');\n const targetDotNpmRcPath = join(outputDirectory, this.outputDir, '.npmrc');\n\n try {\n await stat(sourceDotNpmRcPath);\n await copy(sourceDotNpmRcPath, targetDotNpmRcPath);\n } catch {\n return;\n }\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n { enableSourcemap, enableEsmShim, externals }: BundlerOptions,\n ) {\n const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });\n const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });\n const projectRoot = closestPkgJson ? dirname(closestPkgJson) : process.cwd();\n\n const inputOptions: InputOptions = await getInputOptions(\n mastraEntryFile,\n analyzedBundleInfo,\n this.platform,\n {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n },\n { sourcemap: enableSourcemap, workspaceRoot, projectRoot, enableEsmShim, externalsPreset: externals === true },\n );\n const isVirtual = serverFile.includes('\\n') || !existsSync(serverFile);\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n\n if (isVirtual) {\n inputOptions.input = { index: '#entry', ...toolsInputOptions };\n\n if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.unshift(virtual({ '#entry': serverFile }));\n } else {\n inputOptions.plugins = [virtual({ '#entry': serverFile })];\n }\n } else {\n inputOptions.input = { index: serverFile, ...toolsInputOptions };\n }\n\n return inputOptions;\n }\n\n getAllToolPaths(mastraDir: string, toolsPaths: (string | string[])[] = []): (string | string[])[] {\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedMastraDir = slash(mastraDir);\n\n // Prepare default tools paths with glob patterns\n const defaultToolsPath = posix.join(normalizedMastraDir, 'tools/**/*.{js,ts}');\n const defaultToolsIgnorePaths = [\n `!${posix.join(normalizedMastraDir, 'tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'tools/**/__tests__/**')}`,\n ];\n\n // Combine default path with ignore patterns\n const defaultPaths = [defaultToolsPath, ...defaultToolsIgnorePaths];\n\n // If no tools paths provided, use only the default paths\n if (toolsPaths.length === 0) {\n return [defaultPaths];\n }\n\n // If tools paths are provided, add the default paths to ensure standard tools are always included\n return [...toolsPaths, defaultPaths];\n }\n\n async listToolsInputOptions(toolsPaths: (string | string[])[]) {\n const inputs: Record<string, string> = {};\n\n for (const toolPath of toolsPaths) {\n const expandedPaths = await glob(toolPath, {\n absolute: true,\n expandDirectories: false,\n });\n\n for (const path of expandedPaths) {\n if (await fsExtra.pathExists(path)) {\n const fileService = new FileService();\n const entryFile = fileService.getFirstExistingFile([\n join(path, 'index.ts'),\n join(path, 'index.js'),\n path, // if path itself is a file\n ]);\n\n // if it doesn't exist or is a dir skip it. using a dir as a tool will crash the process\n if (!entryFile || (await stat(entryFile)).isDirectory()) {\n this.logger.warn('No entry file found, skipping', { path });\n continue;\n }\n\n const uniqueToolID = crypto.randomUUID();\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedEntryFile = entryFile.replaceAll('\\\\', '/');\n inputs[`tools/${uniqueToolID}`] = normalizedEntryFile;\n } else {\n this.logger.warn('Tool path does not exist, skipping', { path });\n }\n }\n }\n\n return inputs;\n }\n\n protected async _bundle(\n serverFile: string,\n mastraEntryFile: string,\n {\n projectRoot,\n outputDirectory,\n enableEsmShim = true,\n }: {\n projectRoot: string;\n outputDirectory: string;\n enableEsmShim?: boolean;\n },\n toolsPaths: (string | string[])[] = [],\n bundleLocation: string = join(outputDirectory, this.outputDir),\n ): Promise<void> {\n const analyzeDir = join(outputDirectory, this.analyzeOutputDir);\n\n const bundlerOptions = await this.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n const internalBundlerOptions: BundlerOptions = {\n enableSourcemap: !!bundlerOptions.sourcemap,\n externals: bundlerOptions.externals ?? [],\n enableEsmShim,\n dynamicPackages: bundlerOptions.dynamicPackages,\n };\n\n let analyzedBundleInfo;\n try {\n const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);\n analyzedBundleInfo = await analyzeBundle(\n [serverFile, ...Object.values(resolvedToolsPaths)],\n mastraEntryFile,\n {\n outputDir: analyzeDir,\n projectRoot,\n platform: this.platform,\n bundlerOptions: internalBundlerOptions,\n },\n this.logger,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n if (error instanceof MastraError) {\n throw error;\n }\n\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_ANALYZE_FAILED',\n text: `Failed to analyze Mastra application: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n\n const dependenciesToInstall = new Map<string, ExternalDependencyInfo>();\n for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {\n if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) {\n continue;\n }\n\n dependenciesToInstall.set(dep, depInfo);\n }\n\n try {\n await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall);\n\n this.logger.info('Bundling Mastra application');\n\n const inputOptions: InputOptions = await this.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n internalBundlerOptions,\n );\n\n const bundler = await this.createBundler(\n {\n ...inputOptions,\n logLevel: inputOptions.logLevel === 'silent' ? 'warn' : inputOptions.logLevel,\n onwarn: warning => {\n if (warning.code === 'CIRCULAR_DEPENDENCY') {\n if (warning.ids?.[0]?.includes('node_modules')) {\n return;\n }\n\n this.logger.warn('Circular dependency found', {\n dependency: warning.message.replace('Circular dependency: ', ''),\n });\n }\n },\n },\n {\n dir: bundleLocation,\n manualChunks: {\n mastra: ['#mastra'],\n },\n sourcemap: internalBundlerOptions.enableSourcemap,\n },\n );\n\n await bundler.write();\n const toolImports: string[] = [];\n const toolsExports: string[] = [];\n Array.from(Object.keys(inputOptions.input || {}))\n .filter(key => key.startsWith('tools/'))\n .forEach((key, index) => {\n const toolExport = `tool${index}`;\n toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);\n toolsExports.push(toolExport);\n });\n\n await writeFile(\n join(bundleLocation, 'tools.mjs'),\n `${toolImports.join('\\n')}\n\nexport const tools = [${toolsExports.join(', ')}]`,\n );\n this.logger.info('Bundling Mastra done');\n\n this.logger.info('Copying public files');\n await this.copyPublic(dirname(mastraEntryFile), outputDirectory);\n this.logger.info('Done copying public files');\n\n this.logger.info('Copying .npmrc file');\n await this.copyDOTNPMRC({ outputDirectory, rootDir: projectRoot });\n\n this.logger.info('Done copying .npmrc file');\n\n this.logger.info('Installing dependencies');\n await this.installDependencies(outputDirectory, projectRoot);\n this.logger.info('Done installing dependencies');\n\n this.logger.info('Generating package-lock.json for deploy');\n await this.generateNpmLockfile(join(outputDirectory, this.outputDir));\n this.logger.info('Done generating package-lock.json');\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED',\n text: `Failed during bundler bundle stage: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n }\n\n async lint(_entryFile: string, _outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n const toolsLength = Object.keys(toolsInputOptions).length;\n if (toolsLength > 0) {\n this.logger.info('Found tools', { count: toolsLength });\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk7CT7DAME_cjs = require('./chunk-7CT7DAME.cjs');
|
|
4
4
|
var chunkJZRFRUGM_cjs = require('./chunk-JZRFRUGM.cjs');
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var promises = require('fs/promises');
|
|
@@ -297,22 +297,22 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
|
|
|
297
297
|
}
|
|
298
298
|
plugins.push(
|
|
299
299
|
...[
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
300
|
+
chunk7CT7DAME_cjs.protocolExternalResolver(),
|
|
301
|
+
chunk7CT7DAME_cjs.mastraInternalAliasPlugin(mastraEntry),
|
|
302
|
+
chunk7CT7DAME_cjs.mastraToolsAliasPlugin(),
|
|
303
|
+
chunk7CT7DAME_cjs.tsConfigPaths(),
|
|
304
304
|
json__default.default(),
|
|
305
|
-
|
|
305
|
+
chunk7CT7DAME_cjs.esbuild(),
|
|
306
306
|
commonjs__default.default({
|
|
307
307
|
strictRequires: "debug",
|
|
308
308
|
ignoreTryCatch: false,
|
|
309
309
|
transformMixedEsModules: true,
|
|
310
310
|
extensions: [".js", ".ts"]
|
|
311
311
|
}),
|
|
312
|
-
|
|
312
|
+
chunk7CT7DAME_cjs.removeDeployer(mastraEntry, {
|
|
313
313
|
sourcemap: sourcemapEnabled
|
|
314
314
|
}),
|
|
315
|
-
|
|
315
|
+
chunk7CT7DAME_cjs.esbuild()
|
|
316
316
|
]
|
|
317
317
|
);
|
|
318
318
|
return plugins;
|
|
@@ -329,7 +329,7 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
329
329
|
}
|
|
330
330
|
let entryRootPath = projectRoot;
|
|
331
331
|
if (!output.facadeModuleId.startsWith("\0virtual:")) {
|
|
332
|
-
entryRootPath = await
|
|
332
|
+
entryRootPath = await chunk7CT7DAME_cjs.getPackageRootPath(output.facadeModuleId) || projectRoot;
|
|
333
333
|
}
|
|
334
334
|
for (const [dependency, bindings] of Object.entries(output.importedBindings)) {
|
|
335
335
|
if (!chunkJZRFRUGM_cjs.isBareModuleSpecifier(dependency)) {
|
|
@@ -341,7 +341,7 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
341
341
|
let version;
|
|
342
342
|
let packageSpec;
|
|
343
343
|
if (pkgName) {
|
|
344
|
-
const metadata = await
|
|
344
|
+
const metadata = await chunk7CT7DAME_cjs.getPackageMetadata(dependency, entryRootPath);
|
|
345
345
|
rootPath = metadata.rootPath;
|
|
346
346
|
version = metadata.version;
|
|
347
347
|
packageSpec = metadata.packageSpec;
|
|
@@ -412,7 +412,7 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
412
412
|
let packageSpec;
|
|
413
413
|
let rootPath = null;
|
|
414
414
|
if (pkgName) {
|
|
415
|
-
const metadata = await
|
|
415
|
+
const metadata = await chunk7CT7DAME_cjs.getPackageMetadata(dynamicImport, entryRootPath);
|
|
416
416
|
rootPath = metadata.rootPath;
|
|
417
417
|
version = metadata.version;
|
|
418
418
|
packageSpec = metadata.packageSpec;
|
|
@@ -645,7 +645,7 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
645
645
|
}) {
|
|
646
646
|
const transpilePackagesMap = /* @__PURE__ */ new Map();
|
|
647
647
|
for (const pkg2 of transpilePackages) {
|
|
648
|
-
const dir = await
|
|
648
|
+
const dir = await chunk7CT7DAME_cjs.getPackageRootPath(pkg2);
|
|
649
649
|
if (dir) {
|
|
650
650
|
transpilePackagesMap.set(pkg2, chunkJZRFRUGM_cjs.slash(dir));
|
|
651
651
|
} else {
|
|
@@ -662,10 +662,10 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
662
662
|
{}
|
|
663
663
|
)
|
|
664
664
|
),
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
transpilePackagesMap.size ?
|
|
665
|
+
chunk7CT7DAME_cjs.tsConfigPaths(),
|
|
666
|
+
chunk7CT7DAME_cjs.protocolExternalResolver(),
|
|
667
|
+
chunk7CT7DAME_cjs.subpathExternalsResolver(externals),
|
|
668
|
+
transpilePackagesMap.size ? chunk7CT7DAME_cjs.esbuild({
|
|
669
669
|
format: "esm",
|
|
670
670
|
include: [
|
|
671
671
|
// Match files from transpilePackages by their actual directory paths
|
|
@@ -721,7 +721,7 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
721
721
|
ignoreTryCatch: false
|
|
722
722
|
}),
|
|
723
723
|
bundlerOptions.noBundling ? null : nodeResolve__default.default(chunkJZRFRUGM_cjs.getNodeResolveOptions(platform)),
|
|
724
|
-
bundlerOptions.noBundling ?
|
|
724
|
+
bundlerOptions.noBundling ? chunk7CT7DAME_cjs.esmShim() : null,
|
|
725
725
|
// hono is imported from deployer, so we need to resolve from here instead of the project root
|
|
726
726
|
aliasHono(),
|
|
727
727
|
json__default.default(),
|
|
@@ -965,7 +965,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
965
965
|
return { output, fileNameToDependencyMap, usedExternals };
|
|
966
966
|
}
|
|
967
967
|
function checkConfigExport(result) {
|
|
968
|
-
const t2 = babel2__namespace.
|
|
968
|
+
const t2 = babel2__namespace.types;
|
|
969
969
|
const mastraVars = /* @__PURE__ */ new Set();
|
|
970
970
|
return {
|
|
971
971
|
visitor: {
|
|
@@ -1122,14 +1122,14 @@ async function resolveDependencyInfo(dep, existing, parentPaths) {
|
|
|
1122
1122
|
const packageNames = [...new Set([dep, packageName].filter(Boolean))];
|
|
1123
1123
|
for (const parentPath of parentPaths) {
|
|
1124
1124
|
for (const name of packageNames) {
|
|
1125
|
-
const metadata = await
|
|
1125
|
+
const metadata = await chunk7CT7DAME_cjs.getPackageMetadata(name, parentPath);
|
|
1126
1126
|
if (metadata.version || metadata.packageSpec) {
|
|
1127
1127
|
return preferDependencyInfo(existing, metadata);
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
1131
|
for (const name of packageNames) {
|
|
1132
|
-
const metadata = await
|
|
1132
|
+
const metadata = await chunk7CT7DAME_cjs.getPackageMetadata(name);
|
|
1133
1133
|
if (metadata.version || metadata.packageSpec) {
|
|
1134
1134
|
return preferDependencyInfo(existing, metadata);
|
|
1135
1135
|
}
|
|
@@ -1353,7 +1353,7 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1353
1353
|
await babel2__namespace.transformAsync(mastraConfig, {
|
|
1354
1354
|
filename: mastraEntry,
|
|
1355
1355
|
presets: [undefined("@babel/preset-typescript")],
|
|
1356
|
-
plugins: [checkConfigExport(mastraConfigResult)]
|
|
1356
|
+
plugins: [() => checkConfigExport(mastraConfigResult)]
|
|
1357
1357
|
});
|
|
1358
1358
|
if (!mastraConfigResult.hasValidConfig) {
|
|
1359
1359
|
logger.warn("Invalid Mastra config", {
|
|
@@ -1386,7 +1386,7 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1386
1386
|
});
|
|
1387
1387
|
babel2__namespace.transformSync(analyzeResult.output.code, {
|
|
1388
1388
|
filename: "pino-detection.js",
|
|
1389
|
-
plugins: [detectPinoTransports(detectedPinoTransports)],
|
|
1389
|
+
plugins: [() => detectPinoTransports(detectedPinoTransports)],
|
|
1390
1390
|
configFile: false,
|
|
1391
1391
|
babelrc: false,
|
|
1392
1392
|
code: false
|
|
@@ -1535,5 +1535,5 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1535
1535
|
exports.aliasHono = aliasHono;
|
|
1536
1536
|
exports.analyzeBundle = analyzeBundle;
|
|
1537
1537
|
exports.getWorkspaceInformation = getWorkspaceInformation;
|
|
1538
|
-
//# sourceMappingURL=chunk-
|
|
1539
|
-
//# sourceMappingURL=chunk-
|
|
1538
|
+
//# sourceMappingURL=chunk-XOP6IB66.cjs.map
|
|
1539
|
+
//# sourceMappingURL=chunk-XOP6IB66.cjs.map
|