@mastra/deployer 1.68.0-alpha.0 → 1.68.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/@hono_node-server/package.json +1 -0
- package/dist/_types/@mastra_hono/package.json +1 -0
- package/dist/{analyze-hp4aHpms.cjs → analyze-BC22OIkc.cjs} +109 -94
- package/dist/analyze-BC22OIkc.cjs.map +1 -0
- package/dist/{analyze-B5HY26Tt.js → analyze-D3eRdXC9.js} +107 -91
- package/dist/analyze-D3eRdXC9.js.map +1 -0
- package/dist/{arktype-aI7TBD0R-S0daSmHG.js → arktype-aI7TBD0R-BGjyzmsj.js} +2 -2
- package/dist/{arktype-aI7TBD0R-S0daSmHG.js.map → arktype-aI7TBD0R-BGjyzmsj.js.map} +1 -1
- package/dist/{arktype-aI7TBD0R-BuTX_Phx.cjs → arktype-aI7TBD0R-DCxjN6oF.cjs} +2 -2
- package/dist/{arktype-aI7TBD0R-BuTX_Phx.cjs.map → arktype-aI7TBD0R-DCxjN6oF.cjs.map} +1 -1
- package/dist/build/analyze/analyzeEntry.d.ts +3 -1
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
- package/dist/build/analyze.cjs +1 -1
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +2 -1
- package/dist/build/bundler.d.ts +10 -0
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +2 -2
- package/dist/build/index.cjs +6 -6
- package/dist/build/index.js +6 -6
- package/dist/build/package-info.d.ts +4 -0
- package/dist/build/package-info.d.ts.map +1 -1
- package/dist/build/plugins/tsconfig-paths.d.ts +2 -1
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/{build-Boe3fe3L.js → build-C5eBQq1A.js} +6 -6
- package/dist/{build-Boe3fe3L.js.map → build-C5eBQq1A.js.map} +1 -1
- package/dist/{build-Dit9VFE2.cjs → build-D-GPvP7A.cjs} +6 -6
- package/dist/{build-Dit9VFE2.cjs.map → build-D-GPvP7A.cjs.map} +1 -1
- package/dist/bundler/index.cjs +29 -62
- package/dist/bundler/index.cjs.map +1 -1
- package/dist/bundler/index.d.ts +1 -11
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +30 -63
- package/dist/bundler/index.js.map +1 -1
- package/dist/bundler/workspaceDependencies.d.ts +1 -1
- package/dist/bundler/workspaceDependencies.d.ts.map +1 -1
- package/dist/{bundler-CzQiVHzN.js → bundler-CNFQP4Qm.js} +45 -10
- package/dist/bundler-CNFQP4Qm.js.map +1 -0
- package/dist/{bundler-BKf2S2r_.cjs → bundler-I4HUeik1.cjs} +55 -8
- package/dist/bundler-I4HUeik1.cjs.map +1 -0
- package/dist/{bundlerOptions-I2E5y2Wp.cjs → bundlerOptions-CkFbsVoE.cjs} +2 -2
- package/dist/{bundlerOptions-I2E5y2Wp.cjs.map → bundlerOptions-CkFbsVoE.cjs.map} +1 -1
- package/dist/{bundlerOptions-BSySFLb3.js → bundlerOptions-Dg4pdJsM.js} +2 -2
- package/dist/{bundlerOptions-BSySFLb3.js.map → bundlerOptions-Dg4pdJsM.js.map} +1 -1
- package/dist/core-D3wM1JKp.js +1159 -0
- package/dist/core-D3wM1JKp.js.map +1 -0
- package/dist/core-QL_X0T4Y.cjs +1159 -0
- package/dist/core-QL_X0T4Y.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-deployment-monorepo.md +2 -2
- package/dist/{effect-QlVUlMFu-tf02PTZR.cjs → effect-QlVUlMFu-B2nZ842E.cjs} +3 -3
- package/dist/{effect-QlVUlMFu-tf02PTZR.cjs.map → effect-QlVUlMFu-B2nZ842E.cjs.map} +1 -1
- package/dist/{effect-QlVUlMFu-BN-VJnMF.js → effect-QlVUlMFu-DbWuPaWV.js} +3 -3
- package/dist/{effect-QlVUlMFu-BN-VJnMF.js.map → effect-QlVUlMFu-DbWuPaWV.js.map} +1 -1
- package/dist/{esm-DZ1Siz1C.cjs → esm-Ai6osZ1a.cjs} +61 -50
- package/dist/esm-Ai6osZ1a.cjs.map +1 -0
- package/dist/{esm-B51vJPGv.js → esm-D-wYOO-S.js} +61 -50
- package/dist/esm-D-wYOO-S.js.map +1 -0
- package/dist/{index-CLddUTqr-eO-ae7Sx.js → index-CLddUTqr-BXqo9et4.js} +8 -8
- package/dist/{index-CLddUTqr-eO-ae7Sx.js.map → index-CLddUTqr-BXqo9et4.js.map} +1 -1
- package/dist/{index-CLddUTqr-DS5tJ3WV.cjs → index-CLddUTqr-DsGkVS-W.cjs} +8 -8
- package/dist/{index-CLddUTqr-DS5tJ3WV.cjs.map → index-CLddUTqr-DsGkVS-W.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/server/index.cjs +8 -8
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +8 -8
- package/dist/server/index.js.map +1 -1
- package/dist/services/deps.d.ts +1 -1
- package/dist/services/deps.d.ts.map +1 -1
- package/dist/services/index.cjs +1 -1
- package/dist/services/index.js +1 -1
- package/dist/{services-BLvNG7v7.cjs → services-Beob47UW.cjs} +42 -23
- package/dist/services-Beob47UW.cjs.map +1 -0
- package/dist/{services-B9KRKBT-.js → services-Lm6PRS4D.js} +42 -23
- package/dist/services-Lm6PRS4D.js.map +1 -0
- package/dist/{sury-CWZTCd75-YUPbTtKO.cjs → sury-CWZTCd75-ChXu4j-p.cjs} +3 -3
- package/dist/{sury-CWZTCd75-YUPbTtKO.cjs.map → sury-CWZTCd75-ChXu4j-p.cjs.map} +1 -1
- package/dist/{sury-CWZTCd75-ClSNrMWF.js → sury-CWZTCd75-OKz7uWLi.js} +3 -3
- package/dist/{sury-CWZTCd75-ClSNrMWF.js.map → sury-CWZTCd75-OKz7uWLi.js.map} +1 -1
- package/dist/{typebox-Dei93FPO-CVSJ3SAf.js → typebox-Dei93FPO-C5ACKU09.js} +2 -2
- package/dist/{typebox-Dei93FPO-CVSJ3SAf.js.map → typebox-Dei93FPO-C5ACKU09.js.map} +1 -1
- package/dist/{typebox-Dei93FPO-BTBshlGz.cjs → typebox-Dei93FPO-KTtPU745.cjs} +2 -2
- package/dist/{typebox-Dei93FPO-BTBshlGz.cjs.map → typebox-Dei93FPO-KTtPU745.cjs.map} +1 -1
- package/dist/{utils-DYi43Kp4.js → utils-Bl3Lm7SI.js} +1 -2
- package/dist/{utils-DYi43Kp4.js.map → utils-Bl3Lm7SI.js.map} +1 -1
- package/dist/{utils-7WDNT3Ca.cjs → utils-Bsr_sEcH.cjs} +2 -2
- package/dist/{utils-7WDNT3Ca.cjs.map → utils-Bsr_sEcH.cjs.map} +1 -1
- package/dist/{valibot--1zFm7rT-Dn5WqdyK.cjs → valibot--1zFm7rT-BeX3W1HK.cjs} +3 -3
- package/dist/{valibot--1zFm7rT-Dn5WqdyK.cjs.map → valibot--1zFm7rT-BeX3W1HK.cjs.map} +1 -1
- package/dist/{valibot--1zFm7rT-BxcEC3Pu.js → valibot--1zFm7rT-BuVb-6oJ.js} +3 -3
- package/dist/{valibot--1zFm7rT-BxcEC3Pu.js.map → valibot--1zFm7rT-BuVb-6oJ.js.map} +1 -1
- package/dist/validator/custom-resolver.cjs +1 -1
- package/dist/validator/custom-resolver.js +1 -1
- package/dist/{zod-Bwrt9trS-Bd40XYOT.js → zod-Bwrt9trS-D5b1oyiT.js} +5 -5
- package/dist/{zod-Bwrt9trS-Bd40XYOT.js.map → zod-Bwrt9trS-D5b1oyiT.js.map} +1 -1
- package/dist/{zod-Bwrt9trS-Bi11nE9Q.cjs → zod-Bwrt9trS-DGQs9DWc.cjs} +5 -5
- package/dist/{zod-Bwrt9trS-Bi11nE9Q.cjs.map → zod-Bwrt9trS-DGQs9DWc.cjs.map} +1 -1
- package/package.json +13 -12
- package/dist/analyze-B5HY26Tt.js.map +0 -1
- package/dist/analyze-hp4aHpms.cjs.map +0 -1
- package/dist/bundler-BKf2S2r_.cjs.map +0 -1
- package/dist/bundler-CzQiVHzN.js.map +0 -1
- package/dist/core-D0wEgdn3.cjs +0 -790
- package/dist/core-D0wEgdn3.cjs.map +0 -1
- package/dist/core-DF65PJXc.js +0 -790
- package/dist/core-DF65PJXc.js.map +0 -1
- package/dist/esm-B51vJPGv.js.map +0 -1
- package/dist/esm-DZ1Siz1C.cjs.map +0 -1
- package/dist/services-B9KRKBT-.js.map +0 -1
- package/dist/services-BLvNG7v7.cjs.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as getPackageName, c as isBuiltinModule, f as rollupSafeName, i as getNodeResolveOptions, l as isDependencyPartOfPackage, m as slash, r as getCompiledDepCachePath, s as isBareModuleSpecifier, u as isExternalProtocolImport } from "./utils-
|
|
2
|
-
import { i as DepsService } from "./services-
|
|
3
|
-
import { a as
|
|
4
|
-
import { spawn } from "child_process";
|
|
1
|
+
import { a as getPackageName, c as isBuiltinModule, f as rollupSafeName, i as getNodeResolveOptions, l as isDependencyPartOfPackage, m as slash, r as getCompiledDepCachePath, s as isBareModuleSpecifier, u as isExternalProtocolImport } from "./utils-Bl3Lm7SI.js";
|
|
2
|
+
import { i as DepsService } from "./services-Lm6PRS4D.js";
|
|
3
|
+
import { a as mastraToolsAliasPlugin, c as removeDeployer, d as getPackageInfo$1, f as getPackageMetadata, h as esbuild, i as mastraInternalAliasPlugin, l as protocolExternalResolver, m as esmShim, o as tsConfigPaths, p as getPackageRootPath, s as subpathExternalsResolver } from "./bundler-CNFQP4Qm.js";
|
|
5
4
|
import { existsSync } from "fs";
|
|
6
5
|
import { readFile, writeFile } from "fs/promises";
|
|
7
6
|
import * as path$1 from "path";
|
|
@@ -10,16 +9,16 @@ import { ErrorCategory, ErrorDomain, MastraBaseError, MastraError } from "@mastr
|
|
|
10
9
|
import virtual from "@rollup/plugin-virtual";
|
|
11
10
|
import * as pkg from "empathic/package";
|
|
12
11
|
import { transformAsync, transformSync, types } from "@babel/core";
|
|
13
|
-
import slugify from "@sindresorhus/slugify";
|
|
14
12
|
import { createWorkspacesCache, findWorkspaces, findWorkspacesRoot } from "find-workspaces";
|
|
15
13
|
import { ensureDir } from "fs-extra";
|
|
14
|
+
import { spawn } from "child_process";
|
|
16
15
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
17
16
|
import commonjs from "@rollup/plugin-commonjs";
|
|
18
17
|
import json from "@rollup/plugin-json";
|
|
18
|
+
import { getPackageInfo, resolveModule } from "local-pkg";
|
|
19
19
|
import { rollup } from "rollup";
|
|
20
20
|
import { optimizeLodashImports } from "@optimize-lodash/rollup-plugin";
|
|
21
21
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
22
|
-
import { getPackageInfo } from "local-pkg";
|
|
23
22
|
import { basename as basename$1 } from "path/posix";
|
|
24
23
|
import * as resolve$1 from "resolve.exports";
|
|
25
24
|
//#region \0rolldown/runtime.js
|
|
@@ -139,24 +138,6 @@ var import_stack_trace_parser_cjs = /* @__PURE__ */ __toESM((/* @__PURE__ */ __c
|
|
|
139
138
|
}
|
|
140
139
|
exports.parse = parse;
|
|
141
140
|
})))(), 1);
|
|
142
|
-
const isExportTargetImportable = (target) => {
|
|
143
|
-
if (!target) return false;
|
|
144
|
-
if (typeof target === "string") return true;
|
|
145
|
-
if (Array.isArray(target)) return target.some(isExportTargetImportable);
|
|
146
|
-
if (typeof target !== "object") return false;
|
|
147
|
-
return Object.values(target).some(isExportTargetImportable);
|
|
148
|
-
};
|
|
149
|
-
const hasRootExport = (exportsField) => {
|
|
150
|
-
if (exportsField === void 0) return true;
|
|
151
|
-
if (typeof exportsField === "string" || Array.isArray(exportsField)) return isExportTargetImportable(exportsField);
|
|
152
|
-
if (!exportsField || typeof exportsField !== "object") return false;
|
|
153
|
-
const exportMap = exportsField;
|
|
154
|
-
const exportKeys = Object.keys(exportMap);
|
|
155
|
-
if (exportKeys.length === 0) return false;
|
|
156
|
-
if (Object.prototype.hasOwnProperty.call(exportMap, ".")) return isExportTargetImportable(exportMap["."]);
|
|
157
|
-
if (exportKeys.some((key) => key.startsWith("./"))) return false;
|
|
158
|
-
return isExportTargetImportable(exportMap);
|
|
159
|
-
};
|
|
160
141
|
/**
|
|
161
142
|
* Create a shared cache for find-workspaces
|
|
162
143
|
*/
|
|
@@ -193,7 +174,7 @@ async function getWorkspaceInformation({ dir = process.cwd(), mastraEntryFile })
|
|
|
193
174
|
/**
|
|
194
175
|
* Collects all transitive workspace dependencies and their TGZ paths
|
|
195
176
|
*/
|
|
196
|
-
const collectTransitiveWorkspaceDependencies = ({ workspaceMap, initialDependencies, logger }) => {
|
|
177
|
+
const collectTransitiveWorkspaceDependencies = async ({ workspaceMap, initialDependencies, logger }) => {
|
|
197
178
|
const usedWorkspacePackages = /* @__PURE__ */ new Set();
|
|
198
179
|
const queue = Array.from(initialDependencies);
|
|
199
180
|
const resolutions = {};
|
|
@@ -208,6 +189,7 @@ const collectTransitiveWorkspaceDependencies = ({ workspaceMap, initialDependenc
|
|
|
208
189
|
if (!root) throw new Error("Could not find workspace root");
|
|
209
190
|
const depsService = new DepsService(root.location);
|
|
210
191
|
depsService.__setLogger(logger);
|
|
192
|
+
const slugify = (await import("@sindresorhus/slugify")).default;
|
|
211
193
|
const sanitizedName = slugify(pkgName);
|
|
212
194
|
resolutions[pkgName] = depsService.getWorkspaceDependencyPath({
|
|
213
195
|
pkgName: sanitizedName,
|
|
@@ -231,6 +213,7 @@ const packWorkspaceDependencies = async ({ workspaceMap, usedWorkspacePackages,
|
|
|
231
213
|
const depsService = new DepsService(root.location);
|
|
232
214
|
depsService.__setLogger(logger);
|
|
233
215
|
if (usedWorkspacePackages.size > 0) {
|
|
216
|
+
const slugify = (await import("@sindresorhus/slugify")).default;
|
|
234
217
|
const workspaceDirPath = join(bundleOutputDir, "workspace-module");
|
|
235
218
|
await ensureDir(workspaceDirPath);
|
|
236
219
|
logger.info("Packaging workspace dependencies", { count: usedWorkspacePackages.size });
|
|
@@ -405,7 +388,7 @@ function getInputPlugins$1({ entry, isVirtualFile }, mastraEntry, { sourcemapEna
|
|
|
405
388
|
* Analyzes both static imports and dynamic imports while filtering out Node.js built-ins and ignored dependencies.
|
|
406
389
|
* Identifies workspace packages and resolves package root paths for proper bundling optimization.
|
|
407
390
|
*/
|
|
408
|
-
async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, shouldCheckTransitiveDependencies }) {
|
|
391
|
+
async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, { logger, mastraEntry, shouldCheckTransitiveDependencies, analyzeCache, activeEntries }) {
|
|
409
392
|
const depsToOptimize = /* @__PURE__ */ new Map();
|
|
410
393
|
if (!output.facadeModuleId) throw new Error("Something went wrong, we could not find the package name of the entry file. Please open an issue.");
|
|
411
394
|
let entryRootPath = projectRoot;
|
|
@@ -433,47 +416,55 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
433
416
|
packageSpec
|
|
434
417
|
});
|
|
435
418
|
}
|
|
436
|
-
const
|
|
419
|
+
const processedWorkspaceEntries = /* @__PURE__ */ new Set();
|
|
437
420
|
/**
|
|
438
421
|
* Recursively discovers transitive workspace dependencies from package manifests.
|
|
439
422
|
*/
|
|
440
|
-
function checkTransitiveDependencies(
|
|
441
|
-
if (currentDepth >= maxDepth) {
|
|
442
|
-
logger.warn("Maximum dependency depth reached while checking transitive dependencies.");
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
423
|
+
async function checkTransitiveDependencies() {
|
|
445
424
|
const depsSnapshot = new Map(depsToOptimize);
|
|
446
|
-
let hasAddedDeps = false;
|
|
447
425
|
for (const [dep, meta] of depsSnapshot) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
426
|
+
if (!getPackageName(dep) || !meta.isWorkspace) continue;
|
|
427
|
+
const importerPath = pathToFileURL(output.facadeModuleId.startsWith("\0virtual:") ? mastraEntry || projectRoot : output.facadeModuleId).href;
|
|
428
|
+
const resolvedPath = resolveModule(dep, { paths: [importerPath] });
|
|
429
|
+
if (!resolvedPath) {
|
|
430
|
+
logger.warn("Could not resolve path for workspace dependency", { dep });
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
const resolvedEntry = slash(resolvedPath);
|
|
434
|
+
if (processedWorkspaceEntries.has(resolvedEntry) || activeEntries.has(resolvedEntry)) continue;
|
|
435
|
+
processedWorkspaceEntries.add(resolvedEntry);
|
|
436
|
+
const analysis = await analyzeEntry({
|
|
437
|
+
entry: resolvedPath,
|
|
438
|
+
isVirtualFile: false
|
|
439
|
+
}, mastraEntry, {
|
|
440
|
+
workspaceMap,
|
|
441
|
+
projectRoot,
|
|
442
|
+
logger,
|
|
443
|
+
sourcemapEnabled: false,
|
|
444
|
+
shouldCheckTransitiveDependencies: true,
|
|
445
|
+
analyzeCache,
|
|
446
|
+
activeEntries
|
|
447
|
+
});
|
|
448
|
+
if (!analysis?.dependencies) continue;
|
|
449
|
+
for (const [innerDep, innerMeta] of analysis.dependencies) {
|
|
450
|
+
if (!innerMeta.isWorkspace) continue;
|
|
457
451
|
const existingMeta = depsToOptimize.get(innerDep);
|
|
458
452
|
if (existingMeta) {
|
|
459
453
|
depsToOptimize.set(innerDep, {
|
|
460
454
|
...existingMeta,
|
|
461
|
-
exports:
|
|
455
|
+
exports: [.../* @__PURE__ */ new Set([...existingMeta.exports, ...innerMeta.exports])]
|
|
462
456
|
});
|
|
463
457
|
continue;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
rootPath: slash(innerWorkspaceInfo.location),
|
|
458
|
+
} else depsToOptimize.set(innerDep, {
|
|
459
|
+
exports: innerMeta.exports,
|
|
460
|
+
rootPath: slash(innerMeta.rootPath || ""),
|
|
468
461
|
isWorkspace: true,
|
|
469
|
-
version:
|
|
462
|
+
version: innerMeta.version
|
|
470
463
|
});
|
|
471
|
-
hasAddedDeps = true;
|
|
472
464
|
}
|
|
473
465
|
}
|
|
474
|
-
if (hasAddedDeps) checkTransitiveDependencies(maxDepth, currentDepth + 1);
|
|
475
466
|
}
|
|
476
|
-
if (shouldCheckTransitiveDependencies) checkTransitiveDependencies();
|
|
467
|
+
if (shouldCheckTransitiveDependencies) await checkTransitiveDependencies();
|
|
477
468
|
const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
|
|
478
469
|
if (dynamicImports.length) {
|
|
479
470
|
for (const dynamicImport of dynamicImports) if (!depsToOptimize.has(dynamicImport) && isBareModuleSpecifier(dynamicImport)) {
|
|
@@ -498,37 +489,54 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
498
489
|
}
|
|
499
490
|
return depsToOptimize;
|
|
500
491
|
}
|
|
501
|
-
async function analyzeEntry({ entry, isVirtualFile }, mastraEntry, { logger, sourcemapEnabled, workspaceMap, projectRoot, shouldCheckTransitiveDependencies = false, analyzeCache }) {
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
492
|
+
async function analyzeEntry({ entry, isVirtualFile }, mastraEntry, { logger, sourcemapEnabled, workspaceMap, projectRoot, shouldCheckTransitiveDependencies = false, analyzeCache, activeEntries: providedActiveEntries }) {
|
|
493
|
+
const resolvedEntry = isVirtualFile ? void 0 : slash(entry);
|
|
494
|
+
const effectiveAnalyzeCache = analyzeCache ?? /* @__PURE__ */ new Map();
|
|
495
|
+
const cacheKey = resolvedEntry ? `${resolvedEntry}:${shouldCheckTransitiveDependencies ? "transitive" : "direct"}` : void 0;
|
|
496
|
+
if (cacheKey && effectiveAnalyzeCache.has(cacheKey)) return effectiveAnalyzeCache.get(cacheKey);
|
|
497
|
+
const activeEntries = providedActiveEntries ?? /* @__PURE__ */ new Set();
|
|
498
|
+
const shouldTrackEntry = Boolean(resolvedEntry && !activeEntries.has(resolvedEntry));
|
|
499
|
+
if (resolvedEntry && shouldTrackEntry) activeEntries.add(resolvedEntry);
|
|
500
|
+
try {
|
|
501
|
+
const optimizerBundler = await rollup({
|
|
502
|
+
logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
|
|
503
|
+
input: isVirtualFile ? "#entry" : entry,
|
|
504
|
+
treeshake: false,
|
|
505
|
+
preserveSymlinks: true,
|
|
506
|
+
plugins: getInputPlugins$1({
|
|
507
|
+
entry,
|
|
508
|
+
isVirtualFile
|
|
509
|
+
}, mastraEntry, { sourcemapEnabled }),
|
|
510
|
+
external: DEPS_TO_IGNORE
|
|
511
|
+
});
|
|
512
|
+
const { output } = await (async () => {
|
|
513
|
+
try {
|
|
514
|
+
return await optimizerBundler.generate({
|
|
515
|
+
format: "esm",
|
|
516
|
+
inlineDynamicImports: true
|
|
517
|
+
});
|
|
518
|
+
} finally {
|
|
519
|
+
await optimizerBundler.close();
|
|
520
|
+
}
|
|
521
|
+
})();
|
|
522
|
+
const result = {
|
|
523
|
+
dependencies: await captureDependenciesToOptimize(output[0], workspaceMap, projectRoot, {
|
|
524
|
+
logger,
|
|
525
|
+
mastraEntry,
|
|
526
|
+
shouldCheckTransitiveDependencies,
|
|
527
|
+
analyzeCache: effectiveAnalyzeCache,
|
|
528
|
+
activeEntries
|
|
529
|
+
}),
|
|
530
|
+
output: {
|
|
531
|
+
code: output[0].code,
|
|
532
|
+
map: output[0].map
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
if (cacheKey) effectiveAnalyzeCache.set(cacheKey, result);
|
|
536
|
+
return result;
|
|
537
|
+
} finally {
|
|
538
|
+
if (resolvedEntry && shouldTrackEntry) activeEntries.delete(resolvedEntry);
|
|
539
|
+
}
|
|
532
540
|
}
|
|
533
541
|
//#endregion
|
|
534
542
|
//#region src/build/plugins/hono-alias.ts
|
|
@@ -653,7 +661,7 @@ function createVirtualDependencies(depsToOptimize, { projectRoot, workspaceRoot,
|
|
|
653
661
|
* Configures and returns Rollup plugins for bundling external dependencies.
|
|
654
662
|
* Sets up virtual modules, TypeScript compilation, CommonJS transformation, and workspace resolution.
|
|
655
663
|
*/
|
|
656
|
-
async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, rootDir, externals, platform }) {
|
|
664
|
+
async function getInputPlugins(virtualDependencies, { transpilePackages, workspaceMap, bundlerOptions, projectRoot, rootDir, externals, platform }) {
|
|
657
665
|
const transpilePackagesMap = /* @__PURE__ */ new Map();
|
|
658
666
|
for (const pkg of transpilePackages) {
|
|
659
667
|
const dir = await getPackageRootPath(pkg);
|
|
@@ -665,7 +673,7 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
|
|
|
665
673
|
acc[`#virtual-${dep}`] = virtualDep.virtual;
|
|
666
674
|
return acc;
|
|
667
675
|
}, {})),
|
|
668
|
-
tsConfigPaths(),
|
|
676
|
+
tsConfigPaths({ cwd: projectRoot }),
|
|
669
677
|
protocolExternalResolver(),
|
|
670
678
|
subpathExternalsResolver(externals),
|
|
671
679
|
transpilePackagesMap.size ? esbuild({
|
|
@@ -700,7 +708,11 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
|
|
|
700
708
|
transformMixedEsModules: true,
|
|
701
709
|
ignoreTryCatch: false
|
|
702
710
|
}),
|
|
703
|
-
bundlerOptions.noBundling ? null : nodeResolve(
|
|
711
|
+
bundlerOptions.noBundling ? null : nodeResolve({
|
|
712
|
+
...getNodeResolveOptions(platform),
|
|
713
|
+
rootDir: projectRoot,
|
|
714
|
+
modulePaths: [path$1.join(rootDir, "node_modules")]
|
|
715
|
+
}),
|
|
704
716
|
bundlerOptions.noBundling ? esmShim() : null,
|
|
705
717
|
aliasHono(),
|
|
706
718
|
json(),
|
|
@@ -713,7 +725,7 @@ async function getInputPlugins(virtualDependencies, { transpilePackages, workspa
|
|
|
713
725
|
async handler(id, importer) {
|
|
714
726
|
if (!importer) return null;
|
|
715
727
|
if (!id.endsWith(".node")) return null;
|
|
716
|
-
const packageName = (await getPackageInfo(importer))?.packageJson?.name || id;
|
|
728
|
+
const packageName = (await getPackageInfo$1(importer))?.packageJson?.name || id;
|
|
717
729
|
throw new MastraBaseError({
|
|
718
730
|
id: "DEPLOYER_BUNDLE_EXTERNALS_MISSING_NATIVE_BUILD",
|
|
719
731
|
domain: ErrorDomain.DEPLOYER,
|
|
@@ -741,7 +753,7 @@ export const mastra = new Mastra({
|
|
|
741
753
|
* Executes the Rollup build process for virtual dependencies using configured plugins.
|
|
742
754
|
* Bundles all virtual dependency modules into optimized ESM files with proper external handling.
|
|
743
755
|
*/
|
|
744
|
-
async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, rootDir, outputDir, bundlerOptions, platform }) {
|
|
756
|
+
async function buildExternalDependencies(virtualDependencies, { externals, packagesToTranspile, workspaceMap, projectRoot, rootDir, outputDir, bundlerOptions, platform }) {
|
|
745
757
|
/**
|
|
746
758
|
* If there are no virtual dependencies to bundle, return an empty array to avoid Rollup errors.
|
|
747
759
|
*/
|
|
@@ -751,6 +763,7 @@ async function buildExternalDependencies(virtualDependencies, { externals, packa
|
|
|
751
763
|
transpilePackages: packagesToTranspile,
|
|
752
764
|
workspaceMap,
|
|
753
765
|
bundlerOptions: { noBundling },
|
|
766
|
+
projectRoot,
|
|
754
767
|
rootDir,
|
|
755
768
|
externals,
|
|
756
769
|
platform
|
|
@@ -873,6 +886,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
873
886
|
externals: mergedExternals,
|
|
874
887
|
packagesToTranspile,
|
|
875
888
|
workspaceMap,
|
|
889
|
+
projectRoot,
|
|
876
890
|
rootDir: workspaceRoot || projectRoot,
|
|
877
891
|
outputDir,
|
|
878
892
|
bundlerOptions: {
|
|
@@ -924,13 +938,13 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
924
938
|
//#endregion
|
|
925
939
|
//#region src/build/analyze/externals.ts
|
|
926
940
|
function normalizeExternals(externals) {
|
|
927
|
-
const
|
|
941
|
+
const explicitExternals = Array.isArray(externals) ? externals : [];
|
|
928
942
|
return {
|
|
929
943
|
externalsPreset: externals === true,
|
|
930
944
|
mergedExternals: [...new Set([
|
|
931
945
|
...GLOBAL_EXTERNALS,
|
|
932
946
|
...DEPRECATED_EXTERNALS,
|
|
933
|
-
...
|
|
947
|
+
...explicitExternals
|
|
934
948
|
].filter(Boolean))]
|
|
935
949
|
};
|
|
936
950
|
}
|
|
@@ -1272,6 +1286,7 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
|
|
|
1272
1286
|
logger.info("Analyzing dependencies...");
|
|
1273
1287
|
const allUsedExternals = /* @__PURE__ */ new Map();
|
|
1274
1288
|
const analyzeCache = /* @__PURE__ */ new Map();
|
|
1289
|
+
const activeAnalyzeEntries = /* @__PURE__ */ new Set();
|
|
1275
1290
|
for (const entry of entries) {
|
|
1276
1291
|
const analyzeResult = await analyzeEntry({
|
|
1277
1292
|
entry,
|
|
@@ -1282,7 +1297,8 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
|
|
|
1282
1297
|
workspaceMap,
|
|
1283
1298
|
projectRoot,
|
|
1284
1299
|
shouldCheckTransitiveDependencies: true,
|
|
1285
|
-
analyzeCache
|
|
1300
|
+
analyzeCache,
|
|
1301
|
+
activeEntries: activeAnalyzeEntries
|
|
1286
1302
|
});
|
|
1287
1303
|
transformSync(analyzeResult.output.code, {
|
|
1288
1304
|
filename: "pino-detection.js",
|
|
@@ -1400,4 +1416,4 @@ async function analyzeBundle(entries, mastraEntry, { outputDir, projectRoot, pla
|
|
|
1400
1416
|
//#endregion
|
|
1401
1417
|
export { aliasHono as a, packWorkspaceDependencies as c, bundleExternals as i, checkConfigExport as n, collectTransitiveWorkspaceDependencies as o, normalizeExternals as r, getWorkspaceInformation as s, analyzeBundle as t };
|
|
1402
1418
|
|
|
1403
|
-
//# sourceMappingURL=analyze-
|
|
1419
|
+
//# sourceMappingURL=analyze-D3eRdXC9.js.map
|