@mastra/deployer 1.48.1-alpha.0 → 1.49.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 +18 -0
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +20 -20
- package/dist/build/index.js +5 -5
- package/dist/build/utils.d.ts.map +1 -1
- package/dist/bundler/index.cjs +3 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-IYKMQHY2.cjs → chunk-2XUYQ2EJ.cjs} +25 -25
- package/dist/{chunk-IYKMQHY2.cjs.map → chunk-2XUYQ2EJ.cjs.map} +1 -1
- package/dist/{chunk-FBL7GBNM.cjs → chunk-3JVOVZ2V.cjs} +18 -18
- package/dist/{chunk-FBL7GBNM.cjs.map → chunk-3JVOVZ2V.cjs.map} +1 -1
- package/dist/{chunk-FQC6UUHS.js → chunk-566UDTD4.js} +4 -4
- package/dist/{chunk-FQC6UUHS.js.map → chunk-566UDTD4.js.map} +1 -1
- package/dist/{chunk-I7TERDMR.cjs → chunk-6LWGRT7H.cjs} +5 -5
- package/dist/{chunk-I7TERDMR.cjs.map → chunk-6LWGRT7H.cjs.map} +1 -1
- package/dist/{chunk-VZYB4EVX.cjs → chunk-7RR5PJRM.cjs} +7 -7
- package/dist/{chunk-VZYB4EVX.cjs.map → chunk-7RR5PJRM.cjs.map} +1 -1
- package/dist/{chunk-T6LS4OKA.js → chunk-BYRFFGSN.js} +7 -7
- package/dist/{chunk-T6LS4OKA.js.map → chunk-BYRFFGSN.js.map} +1 -1
- package/dist/{chunk-MPEFRVWJ.js → chunk-CGDATNET.js} +3 -3
- package/dist/{chunk-MPEFRVWJ.js.map → chunk-CGDATNET.js.map} +1 -1
- package/dist/{chunk-CHZ76N6R.cjs → chunk-HMT7QCMZ.cjs} +17 -17
- package/dist/{chunk-CHZ76N6R.cjs.map → chunk-HMT7QCMZ.cjs.map} +1 -1
- package/dist/{chunk-47KJ3RKB.cjs → chunk-IEHRALF6.cjs} +49 -49
- package/dist/{chunk-47KJ3RKB.cjs.map → chunk-IEHRALF6.cjs.map} +1 -1
- package/dist/{chunk-2WEUOK6I.js → chunk-KJ4S6COO.js} +4 -4
- package/dist/{chunk-2WEUOK6I.js.map → chunk-KJ4S6COO.js.map} +1 -1
- package/dist/{chunk-TDNEF2M5.js → chunk-OFMQRNNY.js} +7 -7
- package/dist/{chunk-TDNEF2M5.js.map → chunk-OFMQRNNY.js.map} +1 -1
- package/dist/{chunk-ORSNDVAB.js → chunk-VWD7AY6H.js} +3 -3
- package/dist/{chunk-ORSNDVAB.js.map → chunk-VWD7AY6H.js.map} +1 -1
- package/dist/{chunk-7PMC7SBC.cjs → chunk-WLW5IRHY.cjs} +20 -17
- package/dist/chunk-WLW5IRHY.cjs.map +1 -0
- package/dist/{chunk-V6F2NMS2.js → chunk-Z3DC47CH.js} +20 -17
- package/dist/chunk-Z3DC47CH.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +4 -4
- package/dist/server/index.js +1 -1
- package/dist/validator/custom-resolver.cjs +3 -3
- package/dist/validator/custom-resolver.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-7PMC7SBC.cjs.map +0 -1
- package/dist/chunk-V6F2NMS2.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunk7RR5PJRM_cjs = require('./chunk-7RR5PJRM.cjs');
|
|
4
|
+
var chunkIEHRALF6_cjs = require('./chunk-IEHRALF6.cjs');
|
|
5
|
+
var chunk3JVOVZ2V_cjs = require('./chunk-3JVOVZ2V.cjs');
|
|
6
|
+
var chunk6LWGRT7H_cjs = require('./chunk-6LWGRT7H.cjs');
|
|
7
7
|
var chunkVXLIM7FD_cjs = require('./chunk-VXLIM7FD.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkWLW5IRHY_cjs = require('./chunk-WLW5IRHY.cjs');
|
|
9
9
|
var child_process = require('child_process');
|
|
10
10
|
var fs = require('fs');
|
|
11
11
|
var promises = require('fs/promises');
|
|
@@ -93,7 +93,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
createBundler(inputOptions, outputOptions) {
|
|
96
|
-
return
|
|
96
|
+
return chunk3JVOVZ2V_cjs.createBundler(inputOptions, outputOptions);
|
|
97
97
|
}
|
|
98
98
|
async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
|
|
99
99
|
const defaultBundlerOptions = {
|
|
@@ -103,7 +103,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
103
103
|
[IS_DEFAULT]: true
|
|
104
104
|
};
|
|
105
105
|
try {
|
|
106
|
-
const bundlerOptions = await
|
|
106
|
+
const bundlerOptions = await chunk7RR5PJRM_cjs.getBundlerOptions(mastraEntryFile, outputDirectory);
|
|
107
107
|
return bundlerOptions ?? defaultBundlerOptions;
|
|
108
108
|
} catch (error) {
|
|
109
109
|
this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
|
|
@@ -111,7 +111,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
111
111
|
return defaultBundlerOptions;
|
|
112
112
|
}
|
|
113
113
|
async analyze(entry, mastraFile, outputDirectory) {
|
|
114
|
-
return await
|
|
114
|
+
return await chunkIEHRALF6_cjs.analyzeBundle(
|
|
115
115
|
[].concat(entry),
|
|
116
116
|
mastraFile,
|
|
117
117
|
{
|
|
@@ -182,10 +182,10 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, { enableSourcemap, enableEsmShim, externals }) {
|
|
185
|
-
const { workspaceRoot } = await
|
|
185
|
+
const { workspaceRoot } = await chunkIEHRALF6_cjs.getWorkspaceInformation({ mastraEntryFile });
|
|
186
186
|
const closestPkgJson = pkg__namespace.up({ cwd: path.dirname(mastraEntryFile) });
|
|
187
187
|
const projectRoot = closestPkgJson ? path.dirname(closestPkgJson) : process.cwd();
|
|
188
|
-
const inputOptions = await
|
|
188
|
+
const inputOptions = await chunk3JVOVZ2V_cjs.getInputOptions(
|
|
189
189
|
mastraEntryFile,
|
|
190
190
|
analyzedBundleInfo,
|
|
191
191
|
this.platform,
|
|
@@ -209,7 +209,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
209
209
|
return inputOptions;
|
|
210
210
|
}
|
|
211
211
|
getAllToolPaths(mastraDir, toolsPaths = []) {
|
|
212
|
-
const normalizedMastraDir =
|
|
212
|
+
const normalizedMastraDir = chunkWLW5IRHY_cjs.slash(mastraDir);
|
|
213
213
|
const defaultToolsPath = path.posix.join(normalizedMastraDir, "tools/**/*.{js,ts}");
|
|
214
214
|
const defaultToolsIgnorePaths = [
|
|
215
215
|
`!${path.posix.join(normalizedMastraDir, "tools/**/*.{test,spec}.{js,ts}")}`,
|
|
@@ -267,7 +267,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
267
267
|
let analyzedBundleInfo;
|
|
268
268
|
try {
|
|
269
269
|
const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);
|
|
270
|
-
analyzedBundleInfo = await
|
|
270
|
+
analyzedBundleInfo = await chunkIEHRALF6_cjs.analyzeBundle(
|
|
271
271
|
[serverFile, ...Object.values(resolvedToolsPaths)],
|
|
272
272
|
mastraEntryFile,
|
|
273
273
|
{
|
|
@@ -295,15 +295,15 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
295
295
|
}
|
|
296
296
|
const dependenciesToInstall = /* @__PURE__ */ new Map();
|
|
297
297
|
for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {
|
|
298
|
-
if (analyzedBundleInfo.workspaceMap.has(dep) || !
|
|
298
|
+
if (analyzedBundleInfo.workspaceMap.has(dep) || !chunkWLW5IRHY_cjs.isBareModuleSpecifier(dep)) {
|
|
299
299
|
continue;
|
|
300
300
|
}
|
|
301
301
|
let version = depInfo.version;
|
|
302
302
|
let actualPackageName;
|
|
303
303
|
try {
|
|
304
|
-
let rootPath = await
|
|
304
|
+
let rootPath = await chunk6LWGRT7H_cjs.getPackageRootPath(dep, projectRoot);
|
|
305
305
|
if (!rootPath) {
|
|
306
|
-
rootPath = await
|
|
306
|
+
rootPath = await chunk6LWGRT7H_cjs.getPackageRootPath(dep, undefined);
|
|
307
307
|
}
|
|
308
308
|
if (rootPath) {
|
|
309
309
|
const pkg2 = await fsExtra.readJSON(`${rootPath}/package.json`);
|
|
@@ -406,5 +406,5 @@ export const tools = [${toolsExports.join(", ")}]`
|
|
|
406
406
|
|
|
407
407
|
exports.Bundler = Bundler;
|
|
408
408
|
exports.IS_DEFAULT = IS_DEFAULT;
|
|
409
|
-
//# sourceMappingURL=chunk-
|
|
410
|
-
//# sourceMappingURL=chunk-
|
|
409
|
+
//# sourceMappingURL=chunk-HMT7QCMZ.cjs.map
|
|
410
|
+
//# sourceMappingURL=chunk-HMT7QCMZ.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","getPackageRootPath","readJSON"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BO,IAAM,UAAA,0BAAoB,YAAY;AAEtC,IAAe,OAAA,GAAf,cAA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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-CHZ76N6R.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, readJSON, 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 { getPackageRootPath } from '../build/package-info';\nimport type { BundlerOptions } 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>,\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 if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, value);\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, value);\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 // pnpm v11 requires build policy via pnpm-workspace.yaml in the output directory\n await writeFile(\n join(outputDirectory, 'pnpm-workspace.yaml'),\n \"packages:\\n - '.'\\nallowBuilds:\\n bcrypt: true\\n esbuild: true\\n sharp: true\\n protobufjs: true\\n workerd: true\\n bufferutil: true\\n utf-8-validate: true\\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, string>();\n for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {\n if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) {\n continue;\n }\n\n let version = depInfo.version;\n let actualPackageName: string | undefined;\n\n // Read package.json to get actual package name (for alias detection) and version if not pre-resolved\n try {\n // First try to resolve from the project root (provides correct context for monorepos)\n let rootPath = await getPackageRootPath(dep, projectRoot);\n\n // If not found in user's project, try resolving from deployer's location\n // This handles packages like hono that are provided by @mastra/deployer\n if (!rootPath) {\n rootPath = await getPackageRootPath(dep, import.meta.dirname);\n }\n\n if (rootPath) {\n const pkg = await readJSON(`${rootPath}/package.json`);\n actualPackageName = pkg.name;\n // Use pre-resolved version if available, otherwise use from package.json\n if (!version) {\n version = pkg.version;\n }\n }\n } catch {\n // Resolution failed, will use 'latest' for version\n }\n\n // Default to 'latest' if still no version\n version = version || 'latest';\n\n // Check if this is an npm alias (import name differs from actual package name)\n // e.g., importing \"ai-v5\" which resolves to package \"ai\"\n // or importing \"@ai-sdk/openai-v5\" which resolves to \"@ai-sdk/openai\"\n // In this case, write npm alias syntax: \"ai-v5\": \"npm:ai@5.0.93\"\n const isAlias = actualPackageName && dep !== actualPackageName;\n\n if (isAlias) {\n dependenciesToInstall.set(dep, `npm:${actualPackageName}@${version}`);\n } else {\n dependenciesToInstall.set(dep, version);\n }\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","getPackageRootPath","readJS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,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-HMT7QCMZ.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, readJSON, 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 { getPackageRootPath } from '../build/package-info';\nimport type { BundlerOptions } 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>,\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 if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, value);\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, value);\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 // pnpm v11 requires build policy via pnpm-workspace.yaml in the output directory\n await writeFile(\n join(outputDirectory, 'pnpm-workspace.yaml'),\n \"packages:\\n - '.'\\nallowBuilds:\\n bcrypt: true\\n esbuild: true\\n sharp: true\\n protobufjs: true\\n workerd: true\\n bufferutil: true\\n utf-8-validate: true\\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, string>();\n for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {\n if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) {\n continue;\n }\n\n let version = depInfo.version;\n let actualPackageName: string | undefined;\n\n // Read package.json to get actual package name (for alias detection) and version if not pre-resolved\n try {\n // First try to resolve from the project root (provides correct context for monorepos)\n let rootPath = await getPackageRootPath(dep, projectRoot);\n\n // If not found in user's project, try resolving from deployer's location\n // This handles packages like hono that are provided by @mastra/deployer\n if (!rootPath) {\n rootPath = await getPackageRootPath(dep, import.meta.dirname);\n }\n\n if (rootPath) {\n const pkg = await readJSON(`${rootPath}/package.json`);\n actualPackageName = pkg.name;\n // Use pre-resolved version if available, otherwise use from package.json\n if (!version) {\n version = pkg.version;\n }\n }\n } catch {\n // Resolution failed, will use 'latest' for version\n }\n\n // Default to 'latest' if still no version\n version = version || 'latest';\n\n // Check if this is an npm alias (import name differs from actual package name)\n // e.g., importing \"ai-v5\" which resolves to package \"ai\"\n // or importing \"@ai-sdk/openai-v5\" which resolves to \"@ai-sdk/openai\"\n // In this case, write npm alias syntax: \"ai-v5\": \"npm:ai@5.0.93\"\n const isAlias = actualPackageName && dep !== actualPackageName;\n\n if (isAlias) {\n dependenciesToInstall.set(dep, `npm:${actualPackageName}@${version}`);\n } else {\n dependenciesToInstall.set(dep, version);\n }\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,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk6LWGRT7H_cjs = require('./chunk-6LWGRT7H.cjs');
|
|
4
|
+
var chunkWLW5IRHY_cjs = require('./chunk-WLW5IRHY.cjs');
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var promises = require('fs/promises');
|
|
7
7
|
var path = require('path');
|
|
@@ -157,7 +157,7 @@ async function getWorkspaceInformation({
|
|
|
157
157
|
mastraEntryFile
|
|
158
158
|
}) {
|
|
159
159
|
const closestPkgJson = pkg__namespace.up({ cwd: path.dirname(mastraEntryFile) });
|
|
160
|
-
const location = closestPkgJson ? path.dirname(
|
|
160
|
+
const location = closestPkgJson ? path.dirname(chunkWLW5IRHY_cjs.slash(closestPkgJson)) : chunkWLW5IRHY_cjs.slash(process.cwd());
|
|
161
161
|
const workspaces = await findWorkspaces.findWorkspaces(dir, { cache: workspacesCache });
|
|
162
162
|
const _workspaceMap = new Map(
|
|
163
163
|
workspaces?.map((workspace) => [
|
|
@@ -286,7 +286,7 @@ var DEPRECATED_EXTERNALS = ["fastembed", "nodemailer", "jsdom", "sqlite3"];
|
|
|
286
286
|
|
|
287
287
|
// src/build/analyze/analyzeEntry.ts
|
|
288
288
|
function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }) {
|
|
289
|
-
const normalizedMastraEntry =
|
|
289
|
+
const normalizedMastraEntry = chunkWLW5IRHY_cjs.slash(mastraEntry);
|
|
290
290
|
let virtualPlugin = null;
|
|
291
291
|
if (isVirtualFile) {
|
|
292
292
|
virtualPlugin = virtual__default.default({
|
|
@@ -300,13 +300,13 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
|
|
|
300
300
|
}
|
|
301
301
|
plugins.push(
|
|
302
302
|
...[
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
chunk6LWGRT7H_cjs.tsConfigPaths(),
|
|
304
|
+
chunk6LWGRT7H_cjs.protocolExternalResolver(),
|
|
305
305
|
{
|
|
306
306
|
name: "custom-alias-resolver",
|
|
307
307
|
resolveId(id) {
|
|
308
308
|
if (id === "#server") {
|
|
309
|
-
return
|
|
309
|
+
return chunkWLW5IRHY_cjs.slash(url.fileURLToPath(undefined("@mastra/deployer/server")));
|
|
310
310
|
}
|
|
311
311
|
if (id === "#mastra") {
|
|
312
312
|
return normalizedMastraEntry;
|
|
@@ -317,17 +317,17 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
|
|
|
317
317
|
}
|
|
318
318
|
},
|
|
319
319
|
json__default.default(),
|
|
320
|
-
|
|
320
|
+
chunk6LWGRT7H_cjs.esbuild(),
|
|
321
321
|
commonjs__default.default({
|
|
322
322
|
strictRequires: "debug",
|
|
323
323
|
ignoreTryCatch: false,
|
|
324
324
|
transformMixedEsModules: true,
|
|
325
325
|
extensions: [".js", ".ts"]
|
|
326
326
|
}),
|
|
327
|
-
|
|
327
|
+
chunk6LWGRT7H_cjs.removeDeployer(mastraEntry, {
|
|
328
328
|
sourcemap: sourcemapEnabled
|
|
329
329
|
}),
|
|
330
|
-
|
|
330
|
+
chunk6LWGRT7H_cjs.esbuild()
|
|
331
331
|
]
|
|
332
332
|
);
|
|
333
333
|
return plugins;
|
|
@@ -345,18 +345,18 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
345
345
|
}
|
|
346
346
|
let entryRootPath = projectRoot;
|
|
347
347
|
if (!output.facadeModuleId.startsWith("\0virtual:")) {
|
|
348
|
-
entryRootPath = await
|
|
348
|
+
entryRootPath = await chunk6LWGRT7H_cjs.getPackageRootPath(output.facadeModuleId) || projectRoot;
|
|
349
349
|
}
|
|
350
350
|
for (const [dependency, bindings] of Object.entries(output.importedBindings)) {
|
|
351
|
-
if (!
|
|
351
|
+
if (!chunkWLW5IRHY_cjs.isBareModuleSpecifier(dependency)) {
|
|
352
352
|
continue;
|
|
353
353
|
}
|
|
354
|
-
const pkgName =
|
|
354
|
+
const pkgName = chunkWLW5IRHY_cjs.getPackageName(dependency);
|
|
355
355
|
let rootPath = null;
|
|
356
356
|
let isWorkspace = false;
|
|
357
357
|
let version;
|
|
358
358
|
if (pkgName) {
|
|
359
|
-
rootPath = await
|
|
359
|
+
rootPath = await chunk6LWGRT7H_cjs.getPackageRootPath(dependency, entryRootPath);
|
|
360
360
|
isWorkspace = workspaceMap.has(pkgName);
|
|
361
361
|
if (rootPath) {
|
|
362
362
|
try {
|
|
@@ -366,7 +366,7 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
const normalizedRootPath = rootPath ?
|
|
369
|
+
const normalizedRootPath = rootPath ? chunkWLW5IRHY_cjs.slash(rootPath) : null;
|
|
370
370
|
depsToOptimize.set(dependency, {
|
|
371
371
|
exports: bindings,
|
|
372
372
|
rootPath: normalizedRootPath,
|
|
@@ -426,12 +426,12 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
426
426
|
const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
|
|
427
427
|
if (dynamicImports.length) {
|
|
428
428
|
for (const dynamicImport of dynamicImports) {
|
|
429
|
-
if (!depsToOptimize.has(dynamicImport) &&
|
|
430
|
-
const pkgName =
|
|
429
|
+
if (!depsToOptimize.has(dynamicImport) && chunkWLW5IRHY_cjs.isBareModuleSpecifier(dynamicImport)) {
|
|
430
|
+
const pkgName = chunkWLW5IRHY_cjs.getPackageName(dynamicImport);
|
|
431
431
|
let version;
|
|
432
432
|
let rootPath = null;
|
|
433
433
|
if (pkgName) {
|
|
434
|
-
rootPath = await
|
|
434
|
+
rootPath = await chunk6LWGRT7H_cjs.getPackageRootPath(dynamicImport, entryRootPath);
|
|
435
435
|
if (rootPath) {
|
|
436
436
|
try {
|
|
437
437
|
const pkgJson = await esm.readJSON(`${rootPath}/package.json`);
|
|
@@ -442,7 +442,7 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
442
442
|
}
|
|
443
443
|
depsToOptimize.set(dynamicImport, {
|
|
444
444
|
exports: ["*"],
|
|
445
|
-
rootPath: rootPath ?
|
|
445
|
+
rootPath: rootPath ? chunkWLW5IRHY_cjs.slash(rootPath) : null,
|
|
446
446
|
isWorkspace: false,
|
|
447
447
|
version
|
|
448
448
|
});
|
|
@@ -464,7 +464,7 @@ async function analyzeEntry({
|
|
|
464
464
|
shouldCheckTransitiveDependencies = false,
|
|
465
465
|
analyzeCache
|
|
466
466
|
}) {
|
|
467
|
-
const cacheKey = isVirtualFile ? void 0 :
|
|
467
|
+
const cacheKey = isVirtualFile ? void 0 : chunkWLW5IRHY_cjs.slash(entry);
|
|
468
468
|
if (cacheKey && analyzeCache?.has(cacheKey)) {
|
|
469
469
|
return analyzeCache.get(cacheKey);
|
|
470
470
|
}
|
|
@@ -526,7 +526,7 @@ function moduleResolveMap(externals, projectRoot) {
|
|
|
526
526
|
}
|
|
527
527
|
for (const importedId of info.importedIds) {
|
|
528
528
|
for (const external of externals) {
|
|
529
|
-
if (
|
|
529
|
+
if (chunkWLW5IRHY_cjs.isDependencyPartOfPackage(importedId, external)) {
|
|
530
530
|
importMap.set(external, info.id);
|
|
531
531
|
}
|
|
532
532
|
}
|
|
@@ -538,9 +538,9 @@ function moduleResolveMap(externals, projectRoot) {
|
|
|
538
538
|
if (chunk.type === "chunk") {
|
|
539
539
|
for (const [external, resolvedFrom] of importMap) {
|
|
540
540
|
if (chunk.moduleIds.includes(resolvedFrom)) {
|
|
541
|
-
const fullPath = url.pathToFileURL(
|
|
541
|
+
const fullPath = url.pathToFileURL(chunkWLW5IRHY_cjs.slash(path.join(projectRoot, fileName))).toString();
|
|
542
542
|
const innerMap = resolveMap.get(fullPath) || /* @__PURE__ */ new Map();
|
|
543
|
-
innerMap.set(external, url.pathToFileURL(
|
|
543
|
+
innerMap.set(external, url.pathToFileURL(chunkWLW5IRHY_cjs.slash(resolvedFrom)).toString());
|
|
544
544
|
resolveMap.set(fullPath, innerMap);
|
|
545
545
|
}
|
|
546
546
|
}
|
|
@@ -606,7 +606,7 @@ function nodeGypDetector() {
|
|
|
606
606
|
|
|
607
607
|
// src/build/analyze/bundleExternals.ts
|
|
608
608
|
function prepareEntryFileName(name, rootDir) {
|
|
609
|
-
return
|
|
609
|
+
return chunkWLW5IRHY_cjs.rollupSafeName(name, rootDir);
|
|
610
610
|
}
|
|
611
611
|
function createVirtualDependencies(depsToOptimize, {
|
|
612
612
|
projectRoot,
|
|
@@ -656,7 +656,7 @@ function createVirtualDependencies(depsToOptimize, {
|
|
|
656
656
|
continue;
|
|
657
657
|
}
|
|
658
658
|
const fileName = posix.basename(currentDepPath.name);
|
|
659
|
-
const entryName = prepareEntryFileName(
|
|
659
|
+
const entryName = prepareEntryFileName(chunkWLW5IRHY_cjs.getCompiledDepCachePath(rootPath, fileName), rootDir);
|
|
660
660
|
fileNameToDependencyMap.set(entryName, dep);
|
|
661
661
|
optimizedDependencyEntries.set(dep, {
|
|
662
662
|
...currentDepPath,
|
|
@@ -676,9 +676,9 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
676
676
|
}) {
|
|
677
677
|
const transpilePackagesMap = /* @__PURE__ */ new Map();
|
|
678
678
|
for (const pkg2 of transpilePackages) {
|
|
679
|
-
const dir = await
|
|
679
|
+
const dir = await chunk6LWGRT7H_cjs.getPackageRootPath(pkg2);
|
|
680
680
|
if (dir) {
|
|
681
|
-
transpilePackagesMap.set(pkg2,
|
|
681
|
+
transpilePackagesMap.set(pkg2, chunkWLW5IRHY_cjs.slash(dir));
|
|
682
682
|
} else {
|
|
683
683
|
transpilePackagesMap.set(pkg2, workspaceMap.get(pkg2)?.location ?? pkg2);
|
|
684
684
|
}
|
|
@@ -693,10 +693,10 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
693
693
|
{}
|
|
694
694
|
)
|
|
695
695
|
),
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
transpilePackagesMap.size ?
|
|
696
|
+
chunk6LWGRT7H_cjs.tsConfigPaths(),
|
|
697
|
+
chunk6LWGRT7H_cjs.protocolExternalResolver(),
|
|
698
|
+
chunk6LWGRT7H_cjs.subpathExternalsResolver(externals),
|
|
699
|
+
transpilePackagesMap.size ? chunk6LWGRT7H_cjs.esbuild({
|
|
700
700
|
format: "esm",
|
|
701
701
|
include: [
|
|
702
702
|
// Match files from transpilePackages by their actual directory paths
|
|
@@ -751,8 +751,8 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
751
751
|
transformMixedEsModules: true,
|
|
752
752
|
ignoreTryCatch: false
|
|
753
753
|
}),
|
|
754
|
-
bundlerOptions.noBundling ? null : nodeResolve__default.default(
|
|
755
|
-
bundlerOptions.noBundling ?
|
|
754
|
+
bundlerOptions.noBundling ? null : nodeResolve__default.default(chunkWLW5IRHY_cjs.getNodeResolveOptions(platform)),
|
|
755
|
+
bundlerOptions.noBundling ? chunk6LWGRT7H_cjs.esmShim() : null,
|
|
756
756
|
// hono is imported from deployer, so we need to resolve from here instead of the project root
|
|
757
757
|
aliasHono(),
|
|
758
758
|
json__default.default(),
|
|
@@ -845,9 +845,9 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
845
845
|
if (noBundling) {
|
|
846
846
|
const importedFromPackages = /* @__PURE__ */ new Set();
|
|
847
847
|
for (const moduleId of chunkInfo.moduleIds) {
|
|
848
|
-
const normalized =
|
|
848
|
+
const normalized = chunkWLW5IRHY_cjs.slash(moduleId);
|
|
849
849
|
for (const [pkgName, pkgInfo] of workspaceMap.entries()) {
|
|
850
|
-
const location =
|
|
850
|
+
const location = chunkWLW5IRHY_cjs.slash(pkgInfo.location);
|
|
851
851
|
if (normalized.startsWith(location)) {
|
|
852
852
|
importedFromPackages.add(pkgName);
|
|
853
853
|
break;
|
|
@@ -869,7 +869,7 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
869
869
|
if (importedFromPackages.size === 1) {
|
|
870
870
|
const [pkgName] = importedFromPackages;
|
|
871
871
|
const workspaceLocation = workspaceMap.get(pkgName).location;
|
|
872
|
-
return prepareEntryFileName(
|
|
872
|
+
return prepareEntryFileName(chunkWLW5IRHY_cjs.getCompiledDepCachePath(workspaceLocation, "[name].mjs"), rootDir);
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
return `${outputDirRelative}/[name].mjs`;
|
|
@@ -883,7 +883,7 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
883
883
|
function findExternalImporter(module, external, allOutputs) {
|
|
884
884
|
const capturedFiles = /* @__PURE__ */ new Set();
|
|
885
885
|
for (const id of module.imports) {
|
|
886
|
-
if (
|
|
886
|
+
if (chunkWLW5IRHY_cjs.isDependencyPartOfPackage(id, external)) {
|
|
887
887
|
return module;
|
|
888
888
|
} else {
|
|
889
889
|
if (id.endsWith(".mjs")) {
|
|
@@ -1284,10 +1284,10 @@ async function validateOutput({
|
|
|
1284
1284
|
};
|
|
1285
1285
|
for (const deps of Object.values(usedExternals)) {
|
|
1286
1286
|
for (const dep of Object.keys(deps)) {
|
|
1287
|
-
if (
|
|
1287
|
+
if (chunkWLW5IRHY_cjs.isExternalProtocolImport(dep)) {
|
|
1288
1288
|
continue;
|
|
1289
1289
|
}
|
|
1290
|
-
const pkgName =
|
|
1290
|
+
const pkgName = chunkWLW5IRHY_cjs.getPackageName(dep);
|
|
1291
1291
|
if (pkgName) {
|
|
1292
1292
|
const versionInfo = depsVersionInfo.get(dep) || depsVersionInfo.get(pkgName) || {};
|
|
1293
1293
|
result.externalDependencies.set(pkgName, versionInfo);
|
|
@@ -1370,9 +1370,9 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1370
1370
|
});
|
|
1371
1371
|
await promises.writeFile(path.join(outputDir, `entry-${index++}.mjs`), analyzeResult.output.code);
|
|
1372
1372
|
for (const [dep, metadata] of analyzeResult.dependencies.entries()) {
|
|
1373
|
-
const isPartOfExternals = allExternals.some((external) =>
|
|
1373
|
+
const isPartOfExternals = allExternals.some((external) => chunkWLW5IRHY_cjs.isDependencyPartOfPackage(dep, external));
|
|
1374
1374
|
if (isPartOfExternals || externalsPreset && !metadata.isWorkspace) {
|
|
1375
|
-
const pkgName =
|
|
1375
|
+
const pkgName = chunkWLW5IRHY_cjs.getPackageName(dep);
|
|
1376
1376
|
if (pkgName && !allUsedExternals.has(pkgName)) {
|
|
1377
1377
|
allUsedExternals.set(pkgName, {
|
|
1378
1378
|
version: metadata.version
|
|
@@ -1413,11 +1413,11 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1413
1413
|
platform
|
|
1414
1414
|
});
|
|
1415
1415
|
const relativeWorkspaceFolderPaths = Array.from(workspaceMap.values()).map(
|
|
1416
|
-
(pkgInfo) =>
|
|
1416
|
+
(pkgInfo) => chunkWLW5IRHY_cjs.slash(path.relative(workspaceRoot || projectRoot, pkgInfo.location))
|
|
1417
1417
|
);
|
|
1418
1418
|
const depsVersionInfo = /* @__PURE__ */ new Map();
|
|
1419
1419
|
for (const [dep, metadata] of depsToOptimize.entries()) {
|
|
1420
|
-
const pkgName =
|
|
1420
|
+
const pkgName = chunkWLW5IRHY_cjs.getPackageName(dep);
|
|
1421
1421
|
if (pkgName && metadata.version) {
|
|
1422
1422
|
depsVersionInfo.set(pkgName, {
|
|
1423
1423
|
version: metadata.version
|
|
@@ -1434,19 +1434,19 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1434
1434
|
continue;
|
|
1435
1435
|
}
|
|
1436
1436
|
for (const i of o.imports) {
|
|
1437
|
-
if (
|
|
1437
|
+
if (chunkWLW5IRHY_cjs.isBuiltinModule(i)) {
|
|
1438
1438
|
continue;
|
|
1439
1439
|
}
|
|
1440
1440
|
if (i.startsWith(".") || i.startsWith("/")) {
|
|
1441
1441
|
continue;
|
|
1442
1442
|
}
|
|
1443
|
-
if (!
|
|
1443
|
+
if (!chunkWLW5IRHY_cjs.isBareModuleSpecifier(i) || chunkWLW5IRHY_cjs.isExternalProtocolImport(i)) {
|
|
1444
1444
|
continue;
|
|
1445
1445
|
}
|
|
1446
1446
|
if (relativeWorkspaceFolderPaths.some((workspacePath) => i.startsWith(workspacePath))) {
|
|
1447
1447
|
continue;
|
|
1448
1448
|
}
|
|
1449
|
-
const pkgName =
|
|
1449
|
+
const pkgName = chunkWLW5IRHY_cjs.getPackageName(i);
|
|
1450
1450
|
if (pkgName && !allUsedExternals.has(pkgName)) {
|
|
1451
1451
|
const versionInfo = depsVersionInfo.get(i) || depsVersionInfo.get(pkgName) || {};
|
|
1452
1452
|
allUsedExternals.set(pkgName, versionInfo);
|
|
@@ -1467,7 +1467,7 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1467
1467
|
);
|
|
1468
1468
|
const mergedExternalDeps = new Map(result.externalDependencies);
|
|
1469
1469
|
for (const [dep, info] of allUsedExternals) {
|
|
1470
|
-
if (
|
|
1470
|
+
if (chunkWLW5IRHY_cjs.isExternalProtocolImport(dep)) {
|
|
1471
1471
|
continue;
|
|
1472
1472
|
}
|
|
1473
1473
|
const existing = mergedExternalDeps.get(dep);
|
|
@@ -1494,5 +1494,5 @@ async function analyzeBundle(entries, mastraEntry, {
|
|
|
1494
1494
|
exports.aliasHono = aliasHono;
|
|
1495
1495
|
exports.analyzeBundle = analyzeBundle;
|
|
1496
1496
|
exports.getWorkspaceInformation = getWorkspaceInformation;
|
|
1497
|
-
//# sourceMappingURL=chunk-
|
|
1498
|
-
//# sourceMappingURL=chunk-
|
|
1497
|
+
//# sourceMappingURL=chunk-IEHRALF6.cjs.map
|
|
1498
|
+
//# sourceMappingURL=chunk-IEHRALF6.cjs.map
|