@mastra/deployer 1.0.0-beta.5 → 1.0.0-beta.7
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 +78 -0
- package/dist/arktype-aI7TBD0R-JG4WETGU.js +8 -0
- package/dist/arktype-aI7TBD0R-JG4WETGU.js.map +1 -0
- package/dist/arktype-aI7TBD0R-RMRB5ZNY.cjs +10 -0
- package/dist/arktype-aI7TBD0R-RMRB5ZNY.cjs.map +1 -0
- package/dist/build/analyze/analyzeEntry.d.ts +4 -1
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.d.ts +1 -1
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +13 -13
- package/dist/build/index.js +4 -4
- package/dist/build/plugins/esm-shim.d.ts +14 -0
- package/dist/build/plugins/esm-shim.d.ts.map +1 -0
- package/dist/build/plugins/module-resolve-map.d.ts +3 -0
- package/dist/build/plugins/module-resolve-map.d.ts.map +1 -0
- package/dist/build/plugins/node-gyp-detector.d.ts +3 -0
- package/dist/build/plugins/node-gyp-detector.d.ts.map +1 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts +3 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts.map +1 -0
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/build/utils.d.ts +1 -0
- package/dist/build/utils.d.ts.map +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.ts +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/chunk-2NO5NO4J.js +93 -0
- package/dist/chunk-2NO5NO4J.js.map +1 -0
- package/dist/chunk-2OTEFUER.cjs +69 -0
- package/dist/chunk-2OTEFUER.cjs.map +1 -0
- package/dist/chunk-46SXOVGO.js +159 -0
- package/dist/chunk-46SXOVGO.js.map +1 -0
- package/dist/chunk-4YYZKC2P.cjs +4 -0
- package/dist/chunk-4YYZKC2P.cjs.map +1 -0
- package/dist/chunk-5CWPEG6R.js +62 -0
- package/dist/chunk-5CWPEG6R.js.map +1 -0
- package/dist/{chunk-QBQY35KA.js → chunk-7G2FA6KY.js} +6 -5
- package/dist/chunk-7G2FA6KY.js.map +1 -0
- package/dist/chunk-BJURVMEW.cjs +16 -0
- package/dist/chunk-BJURVMEW.cjs.map +1 -0
- package/dist/{chunk-5QFG6SCM.js → chunk-DPDWM7HQ.js} +2 -2
- package/dist/chunk-DPDWM7HQ.js.map +1 -0
- package/dist/chunk-HXYLK6CH.js +3 -0
- package/dist/chunk-HXYLK6CH.js.map +1 -0
- package/dist/chunk-IL36YSXF.cjs +8 -0
- package/dist/chunk-IL36YSXF.cjs.map +1 -0
- package/dist/chunk-IR2ZJ7CP.cjs +95 -0
- package/dist/chunk-IR2ZJ7CP.cjs.map +1 -0
- package/dist/{chunk-3JYRSECU.cjs → chunk-JVBCN3RH.cjs} +4 -4
- package/dist/chunk-JVBCN3RH.cjs.map +1 -0
- package/dist/chunk-L4SN27ZE.js +14 -0
- package/dist/chunk-L4SN27ZE.js.map +1 -0
- package/dist/{chunk-WFL4V5AW.cjs → chunk-MC37X2IH.cjs} +565 -192
- package/dist/chunk-MC37X2IH.cjs.map +1 -0
- package/dist/{chunk-Z7TBDRZ7.cjs → chunk-N6GC4R2P.cjs} +13 -23
- package/dist/chunk-N6GC4R2P.cjs.map +1 -0
- package/dist/chunk-NZ47MQSD.cjs +162 -0
- package/dist/chunk-NZ47MQSD.cjs.map +1 -0
- package/dist/{chunk-EM3VETMX.js → chunk-O2KU7J7Q.js} +5 -4
- package/dist/chunk-O2KU7J7Q.js.map +1 -0
- package/dist/{chunk-NVCHGD24.cjs → chunk-ORHTXAPI.cjs} +15 -14
- package/dist/chunk-ORHTXAPI.cjs.map +1 -0
- package/dist/chunk-PDVYEX76.js +6 -0
- package/dist/chunk-PDVYEX76.js.map +1 -0
- package/dist/{chunk-6S5GQUS6.cjs → chunk-PMRHMMAQ.cjs} +16 -15
- package/dist/chunk-PMRHMMAQ.cjs.map +1 -0
- package/dist/{chunk-Z7KK37HD.js → chunk-SRCHVFND.js} +6 -15
- package/dist/chunk-SRCHVFND.js.map +1 -0
- package/dist/{chunk-NK3AYZ6D.js → chunk-UEFVUIPU.js} +549 -175
- package/dist/chunk-UEFVUIPU.js.map +1 -0
- package/dist/default-u_dwuiYb-MRYQILW4.js +3 -0
- package/dist/default-u_dwuiYb-MRYQILW4.js.map +1 -0
- package/dist/default-u_dwuiYb-WPBHZH2R.cjs +9 -0
- package/dist/default-u_dwuiYb-WPBHZH2R.cjs.map +1 -0
- package/dist/deploy/log.d.ts +1 -1
- package/dist/deploy/log.d.ts.map +1 -1
- package/dist/effect-QlVUlMFu-N7VAYT2B.cjs +17 -0
- package/dist/effect-QlVUlMFu-N7VAYT2B.cjs.map +1 -0
- package/dist/effect-QlVUlMFu-NH625H3V.js +15 -0
- package/dist/effect-QlVUlMFu-NH625H3V.js.map +1 -0
- package/dist/esm-BZAOWJTI.cjs +1336 -0
- package/dist/esm-BZAOWJTI.cjs.map +1 -0
- package/dist/esm-T7FR74HN.js +1289 -0
- package/dist/esm-T7FR74HN.js.map +1 -0
- package/dist/index.cjs +12 -12
- package/dist/index.js +4 -4
- package/dist/server/index.cjs +1113 -1508
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1101 -1496
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.js +1 -1
- package/dist/sury-CWZTCd75-E5BDQIXB.cjs +17 -0
- package/dist/sury-CWZTCd75-E5BDQIXB.cjs.map +1 -0
- package/dist/sury-CWZTCd75-HWBNYVQW.js +15 -0
- package/dist/sury-CWZTCd75-HWBNYVQW.js.map +1 -0
- package/dist/typebox-Dei93FPO-42ICWLXF.cjs +10 -0
- package/dist/typebox-Dei93FPO-42ICWLXF.cjs.map +1 -0
- package/dist/typebox-Dei93FPO-XXPZXWWK.js +8 -0
- package/dist/typebox-Dei93FPO-XXPZXWWK.js.map +1 -0
- package/dist/valibot--1zFm7rT-ALWQ34TP.cjs +17 -0
- package/dist/valibot--1zFm7rT-ALWQ34TP.cjs.map +1 -0
- package/dist/valibot--1zFm7rT-W6DSEVCL.js +15 -0
- package/dist/valibot--1zFm7rT-W6DSEVCL.js.map +1 -0
- package/dist/valibot-D_HTw1Gn-LVFT5X5F.js +43 -0
- package/dist/valibot-D_HTw1Gn-LVFT5X5F.js.map +1 -0
- package/dist/valibot-D_HTw1Gn-PN7GEV4F.cjs +45 -0
- package/dist/valibot-D_HTw1Gn-PN7GEV4F.cjs.map +1 -0
- package/dist/validator/custom-resolver.cjs +20 -12
- package/dist/validator/custom-resolver.cjs.map +1 -1
- package/dist/validator/custom-resolver.d.ts.map +1 -1
- package/dist/validator/custom-resolver.js +18 -10
- package/dist/validator/custom-resolver.js.map +1 -1
- package/dist/validator/validate.d.ts +15 -1
- package/dist/validator/validate.d.ts.map +1 -1
- package/dist/zod-Bwrt9trS-C5ATNTZG.cjs +31 -0
- package/dist/zod-Bwrt9trS-C5ATNTZG.cjs.map +1 -0
- package/dist/zod-Bwrt9trS-UDAV5VDV.js +29 -0
- package/dist/zod-Bwrt9trS-UDAV5VDV.js.map +1 -0
- package/dist/zod-DSgpEGAE-AVWGGTUD.js +37 -0
- package/dist/zod-DSgpEGAE-AVWGGTUD.js.map +1 -0
- package/dist/zod-DSgpEGAE-EH7N2QK7.cjs +39 -0
- package/dist/zod-DSgpEGAE-EH7N2QK7.cjs.map +1 -0
- package/package.json +8 -6
- package/dist/chunk-3JYRSECU.cjs.map +0 -1
- package/dist/chunk-5QFG6SCM.js.map +0 -1
- package/dist/chunk-6S5GQUS6.cjs.map +0 -1
- package/dist/chunk-EM3VETMX.js.map +0 -1
- package/dist/chunk-NK3AYZ6D.js.map +0 -1
- package/dist/chunk-NVCHGD24.cjs.map +0 -1
- package/dist/chunk-QBQY35KA.js.map +0 -1
- package/dist/chunk-WFL4V5AW.cjs.map +0 -1
- package/dist/chunk-Z7KK37HD.js.map +0 -1
- package/dist/chunk-Z7TBDRZ7.cjs.map +0 -1
- package/dist/server/handlers/auth/defaults.d.ts +0 -3
- package/dist/server/handlers/auth/defaults.d.ts.map +0 -1
- package/dist/server/handlers/auth/helpers.d.ts +0 -11
- package/dist/server/handlers/auth/helpers.d.ts.map +0 -1
- package/dist/server/handlers/auth/index.d.ts +0 -11
- package/dist/server/handlers/auth/index.d.ts.map +0 -1
- package/dist/server/handlers/mcp.d.ts +0 -86
- package/dist/server/handlers/mcp.d.ts.map +0 -1
- package/dist/server/schemas/mcp.d.ts +0 -230
- package/dist/server/schemas/mcp.d.ts.map +0 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunk2OTEFUER_cjs = require('./chunk-2OTEFUER.cjs');
|
|
3
4
|
var babel = require('@babel/core');
|
|
4
5
|
var fs = require('fs');
|
|
5
6
|
var promises = require('fs/promises');
|
|
6
7
|
var path2 = require('path');
|
|
7
8
|
var child_process = require('child_process');
|
|
8
|
-
var localPkg = require('local-pkg');
|
|
9
|
-
var url = require('url');
|
|
10
9
|
var rollup = require('rollup');
|
|
11
10
|
var originalEsbuild = require('rollup-plugin-esbuild');
|
|
12
11
|
var commonjs = require('@rollup/plugin-commonjs');
|
|
@@ -18,11 +17,13 @@ var pkg = require('empathic/package');
|
|
|
18
17
|
var findWorkspaces = require('find-workspaces');
|
|
19
18
|
var logger = require('@mastra/core/logger');
|
|
20
19
|
var virtual = require('@rollup/plugin-virtual');
|
|
20
|
+
var url = require('url');
|
|
21
21
|
var module$1 = require('module');
|
|
22
22
|
var nodeResolve = require('@rollup/plugin-node-resolve');
|
|
23
|
-
var
|
|
23
|
+
var originalEsmShim = require('@rollup/plugin-esm-shim');
|
|
24
24
|
var posix = require('path/posix');
|
|
25
25
|
var resolve = require('resolve.exports');
|
|
26
|
+
var localPkg = require('local-pkg');
|
|
26
27
|
var error = require('@mastra/core/error');
|
|
27
28
|
|
|
28
29
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -55,86 +56,21 @@ var json__default = /*#__PURE__*/_interopDefault(json);
|
|
|
55
56
|
var pkg__namespace = /*#__PURE__*/_interopNamespace(pkg);
|
|
56
57
|
var virtual__default = /*#__PURE__*/_interopDefault(virtual);
|
|
57
58
|
var nodeResolve__default = /*#__PURE__*/_interopDefault(nodeResolve);
|
|
58
|
-
var
|
|
59
|
+
var originalEsmShim__default = /*#__PURE__*/_interopDefault(originalEsmShim);
|
|
59
60
|
var resolve__namespace = /*#__PURE__*/_interopNamespace(resolve);
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
async function getPackageRootPath(packageName, parentPath) {
|
|
70
|
-
let rootPath;
|
|
71
|
-
try {
|
|
72
|
-
let options = void 0;
|
|
73
|
-
if (parentPath) {
|
|
74
|
-
if (!parentPath.startsWith("file://")) {
|
|
75
|
-
parentPath = url.pathToFileURL(parentPath).href;
|
|
76
|
-
}
|
|
77
|
-
options = {
|
|
78
|
-
paths: [parentPath]
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
const pkg2 = await localPkg.getPackageInfo(packageName, options);
|
|
82
|
-
rootPath = pkg2?.rootPath ?? null;
|
|
83
|
-
} catch (e) {
|
|
84
|
-
rootPath = null;
|
|
85
|
-
}
|
|
86
|
-
return rootPath;
|
|
87
|
-
}
|
|
88
|
-
function getCompiledDepCachePath(rootPath, packageName) {
|
|
89
|
-
return slash(path2.join(rootPath, "node_modules", ".cache", packageName));
|
|
90
|
-
}
|
|
91
|
-
function slash(path3) {
|
|
92
|
-
const isExtendedLengthPath = path3.startsWith("\\\\?\\");
|
|
93
|
-
if (isExtendedLengthPath) {
|
|
94
|
-
return path3;
|
|
95
|
-
}
|
|
96
|
-
return path3.replaceAll("\\", "/");
|
|
97
|
-
}
|
|
98
|
-
function rollupSafeName(name, rootDir) {
|
|
99
|
-
const rel = path2.relative(rootDir, name);
|
|
100
|
-
let entry = slash(rel);
|
|
101
|
-
entry = entry.replace(/^(\.\.\/)+/, "");
|
|
102
|
-
entry = entry.replace(/^\/+/, "");
|
|
103
|
-
entry = entry.replace(/^[A-Za-z]:\//, "");
|
|
104
|
-
if (!entry) {
|
|
105
|
-
entry = slash(path2.basename(name));
|
|
62
|
+
var ValidationError = class extends Error {
|
|
63
|
+
type;
|
|
64
|
+
stack;
|
|
65
|
+
constructor(args) {
|
|
66
|
+
super(args.message);
|
|
67
|
+
this.type = args.type;
|
|
68
|
+
this.stack = args.stack;
|
|
106
69
|
}
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
var NATIVE_BINDING_LOADERS = [
|
|
110
|
-
"node-gyp-build",
|
|
111
|
-
"prebuild-install",
|
|
112
|
-
"bindings",
|
|
113
|
-
"node-addon-api",
|
|
114
|
-
"node-pre-gyp",
|
|
115
|
-
"nan"
|
|
116
|
-
// Native Abstractions for Node.js
|
|
117
|
-
];
|
|
118
|
-
function findNativePackageModule(moduleIds) {
|
|
119
|
-
return moduleIds.find((id) => {
|
|
120
|
-
if (id.startsWith("\0")) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
if (!id.includes("/node_modules/")) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
for (const loader of NATIVE_BINDING_LOADERS) {
|
|
127
|
-
if (id.includes(`/${loader}/`) || id.includes(`/${loader}@`)) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// src/validator/validate.ts
|
|
70
|
+
};
|
|
136
71
|
function spawn(command, args = [], options = {}) {
|
|
137
72
|
return new Promise((resolve2, reject) => {
|
|
73
|
+
let validationError = null;
|
|
138
74
|
const childProcess = child_process.spawn(command, args, {
|
|
139
75
|
// stdio: 'inherit',
|
|
140
76
|
...options
|
|
@@ -144,28 +80,63 @@ function spawn(command, args = [], options = {}) {
|
|
|
144
80
|
});
|
|
145
81
|
let stderr = "";
|
|
146
82
|
childProcess.stderr?.on("data", (message) => {
|
|
147
|
-
|
|
83
|
+
try {
|
|
84
|
+
validationError = JSON.parse(message.toString());
|
|
85
|
+
} catch {
|
|
86
|
+
stderr += message;
|
|
87
|
+
}
|
|
148
88
|
});
|
|
149
89
|
childProcess.on("close", (code) => {
|
|
150
90
|
if (code === 0) {
|
|
151
91
|
resolve2();
|
|
152
92
|
} else {
|
|
153
|
-
|
|
93
|
+
if (validationError) {
|
|
94
|
+
reject(new ValidationError(validationError));
|
|
95
|
+
} else {
|
|
96
|
+
reject(new Error(stderr));
|
|
97
|
+
}
|
|
154
98
|
}
|
|
155
99
|
});
|
|
156
100
|
});
|
|
157
101
|
}
|
|
158
|
-
function validate(file) {
|
|
102
|
+
function validate(file, { injectESMShim = false, moduleResolveMapLocation }) {
|
|
103
|
+
let prefixCode = "";
|
|
104
|
+
if (injectESMShim) {
|
|
105
|
+
prefixCode = `import { fileURLToPath } from 'url';
|
|
106
|
+
import { dirname } from 'path';
|
|
107
|
+
|
|
108
|
+
globalThis.__filename = fileURLToPath(import.meta.url);
|
|
109
|
+
globalThis.__dirname = dirname(__filename);
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
function errorHandler(err) {
|
|
113
|
+
console.error(
|
|
114
|
+
JSON.stringify({
|
|
115
|
+
type: err.name,
|
|
116
|
+
message: err.message,
|
|
117
|
+
stack: err.stack
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
159
122
|
return spawn(
|
|
160
|
-
|
|
123
|
+
process.execPath,
|
|
161
124
|
[
|
|
162
125
|
"--import",
|
|
163
126
|
undefined("@mastra/deployer/loader"),
|
|
164
127
|
"--input-type=module",
|
|
128
|
+
"--enable-source-maps",
|
|
165
129
|
"-e",
|
|
166
|
-
|
|
130
|
+
`${prefixCode};import('file://${chunk2OTEFUER_cjs.slash(file)}').catch(err => {
|
|
131
|
+
${errorHandler.toString()}
|
|
132
|
+
errorHandler(err);
|
|
133
|
+
})`.replaceAll(/\n/g, "")
|
|
167
134
|
],
|
|
168
135
|
{
|
|
136
|
+
env: {
|
|
137
|
+
...process.env,
|
|
138
|
+
MODULE_MAP: `${moduleResolveMapLocation}`
|
|
139
|
+
},
|
|
169
140
|
cwd: path2.dirname(file)
|
|
170
141
|
}
|
|
171
142
|
);
|
|
@@ -261,28 +232,88 @@ function esbuild(options = {}) {
|
|
|
261
232
|
}
|
|
262
233
|
var PLUGIN_NAME = "tsconfig-paths";
|
|
263
234
|
function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
|
|
264
|
-
|
|
235
|
+
const handlerCache = /* @__PURE__ */ new Map();
|
|
236
|
+
function findTsConfigForFile(filePath) {
|
|
237
|
+
let currentDir = path2__namespace.default.dirname(filePath);
|
|
238
|
+
const root = path2__namespace.default.parse(currentDir).root;
|
|
239
|
+
while (currentDir !== root) {
|
|
240
|
+
const tsConfigPath2 = path2__namespace.default.join(currentDir, "tsconfig.json");
|
|
241
|
+
if (fs__default.default.existsSync(tsConfigPath2)) {
|
|
242
|
+
if (hasPaths(tsConfigPath2)) {
|
|
243
|
+
return tsConfigPath2;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const tsConfigBasePath = path2__namespace.default.join(currentDir, "tsconfig.base.json");
|
|
247
|
+
if (fs__default.default.existsSync(tsConfigBasePath)) {
|
|
248
|
+
if (hasPaths(tsConfigBasePath)) {
|
|
249
|
+
return tsConfigBasePath;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
currentDir = path2__namespace.default.dirname(currentDir);
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
function hasPaths(tsConfigPath2) {
|
|
257
|
+
try {
|
|
258
|
+
const config = JSON.parse(fs__default.default.readFileSync(tsConfigPath2, "utf8"));
|
|
259
|
+
return !!(config.compilerOptions?.paths && Object.keys(config.compilerOptions.paths).length > 0);
|
|
260
|
+
} catch {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function getHandlerForFile(filePath) {
|
|
265
|
+
if (tsConfigPath && typeof tsConfigPath === "string") {
|
|
266
|
+
if (!handlerCache.has(tsConfigPath)) {
|
|
267
|
+
handlerCache.set(
|
|
268
|
+
tsConfigPath,
|
|
269
|
+
typescriptPaths.createHandler({
|
|
270
|
+
log: () => {
|
|
271
|
+
},
|
|
272
|
+
tsConfigPath,
|
|
273
|
+
respectCoreModule,
|
|
274
|
+
falllback: (moduleName) => fs__default.default.existsSync(moduleName)
|
|
275
|
+
})
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
return handlerCache.get(tsConfigPath);
|
|
279
|
+
}
|
|
280
|
+
const configPath = findTsConfigForFile(filePath);
|
|
281
|
+
if (!configPath) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
if (!handlerCache.has(configPath)) {
|
|
285
|
+
handlerCache.set(
|
|
286
|
+
configPath,
|
|
287
|
+
typescriptPaths.createHandler({
|
|
288
|
+
log: () => {
|
|
289
|
+
},
|
|
290
|
+
tsConfigPath: configPath,
|
|
291
|
+
respectCoreModule,
|
|
292
|
+
falllback: (moduleName) => fs__default.default.existsSync(moduleName)
|
|
293
|
+
})
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
return handlerCache.get(configPath);
|
|
297
|
+
}
|
|
298
|
+
function resolveAlias(request, importer) {
|
|
299
|
+
const dynamicHandler = getHandlerForFile(importer);
|
|
300
|
+
if (!dynamicHandler) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
const resolved = dynamicHandler(request, path2.normalize(importer));
|
|
304
|
+
return resolved;
|
|
305
|
+
}
|
|
265
306
|
return {
|
|
266
307
|
name: PLUGIN_NAME,
|
|
267
|
-
buildStart() {
|
|
268
|
-
handler = typescriptPaths.createHandler({
|
|
269
|
-
log: () => {
|
|
270
|
-
},
|
|
271
|
-
tsConfigPath,
|
|
272
|
-
respectCoreModule,
|
|
273
|
-
falllback: (moduleName) => fs__default.default.existsSync(moduleName)
|
|
274
|
-
});
|
|
275
|
-
return;
|
|
276
|
-
},
|
|
277
308
|
async resolveId(request, importer, options) {
|
|
278
|
-
if (!importer || request.startsWith("\0")) {
|
|
309
|
+
if (!importer || request.startsWith("\0") || importer.charCodeAt(0) === 0) {
|
|
279
310
|
return null;
|
|
280
311
|
}
|
|
281
|
-
const moduleName =
|
|
312
|
+
const moduleName = resolveAlias(request, importer);
|
|
282
313
|
if (!moduleName) {
|
|
283
314
|
let importerMeta = {};
|
|
284
|
-
const
|
|
285
|
-
if (!
|
|
315
|
+
const resolved2 = await this.resolve(request, importer, { skipSelf: true, ...options });
|
|
316
|
+
if (!resolved2) {
|
|
286
317
|
return null;
|
|
287
318
|
}
|
|
288
319
|
if (localResolve) {
|
|
@@ -290,37 +321,42 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
|
|
|
290
321
|
importerMeta = importerInfo?.meta || {};
|
|
291
322
|
if (!request.startsWith("./") && !request.startsWith("../") && importerMeta?.[PLUGIN_NAME]?.resolved) {
|
|
292
323
|
return {
|
|
293
|
-
...
|
|
324
|
+
...resolved2,
|
|
294
325
|
external: !request.startsWith("hono/") && request !== "hono"
|
|
295
326
|
};
|
|
296
327
|
}
|
|
297
328
|
}
|
|
298
329
|
return {
|
|
299
|
-
...
|
|
330
|
+
...resolved2,
|
|
300
331
|
meta: {
|
|
301
|
-
...
|
|
332
|
+
...resolved2.meta || {},
|
|
302
333
|
...importerMeta
|
|
303
334
|
}
|
|
304
335
|
};
|
|
305
336
|
}
|
|
306
337
|
if (!path2__namespace.default.extname(moduleName)) {
|
|
307
|
-
const
|
|
308
|
-
if (!
|
|
338
|
+
const resolved2 = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
|
|
339
|
+
if (!resolved2) {
|
|
309
340
|
return null;
|
|
310
341
|
}
|
|
311
342
|
return {
|
|
312
|
-
...
|
|
343
|
+
...resolved2,
|
|
313
344
|
meta: {
|
|
314
|
-
...
|
|
345
|
+
...resolved2.meta,
|
|
315
346
|
[PLUGIN_NAME]: {
|
|
316
347
|
resolved: true
|
|
317
348
|
}
|
|
318
349
|
}
|
|
319
350
|
};
|
|
320
351
|
}
|
|
352
|
+
const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
|
|
353
|
+
if (!resolved) {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
321
356
|
return {
|
|
322
|
-
|
|
357
|
+
...resolved,
|
|
323
358
|
meta: {
|
|
359
|
+
...resolved.meta,
|
|
324
360
|
[PLUGIN_NAME]: {
|
|
325
361
|
resolved: true
|
|
326
362
|
}
|
|
@@ -539,7 +575,7 @@ async function getWorkspaceInformation({
|
|
|
539
575
|
mastraEntryFile
|
|
540
576
|
}) {
|
|
541
577
|
const closestPkgJson = pkg__namespace.up({ cwd: path2.dirname(mastraEntryFile) });
|
|
542
|
-
const location = closestPkgJson ? path2.dirname(slash(closestPkgJson)) : slash(process.cwd());
|
|
578
|
+
const location = closestPkgJson ? path2.dirname(chunk2OTEFUER_cjs.slash(closestPkgJson)) : chunk2OTEFUER_cjs.slash(process.cwd());
|
|
543
579
|
const workspaces = await findWorkspaces.findWorkspaces(dir, { cache: workspacesCache });
|
|
544
580
|
const _workspaceMap = new Map(
|
|
545
581
|
workspaces?.map((workspace) => [
|
|
@@ -655,7 +691,7 @@ var DEPRECATED_EXTERNALS = ["fastembed", "nodemailer", "jsdom", "sqlite3"];
|
|
|
655
691
|
|
|
656
692
|
// src/build/analyze/analyzeEntry.ts
|
|
657
693
|
function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabled }) {
|
|
658
|
-
const normalizedMastraEntry = slash(mastraEntry);
|
|
694
|
+
const normalizedMastraEntry = chunk2OTEFUER_cjs.slash(mastraEntry);
|
|
659
695
|
let virtualPlugin = null;
|
|
660
696
|
if (isVirtualFile) {
|
|
661
697
|
virtualPlugin = virtual__default.default({
|
|
@@ -674,7 +710,7 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
|
|
|
674
710
|
name: "custom-alias-resolver",
|
|
675
711
|
resolveId(id) {
|
|
676
712
|
if (id === "#server") {
|
|
677
|
-
return slash(url.fileURLToPath(undefined("@mastra/deployer/server")));
|
|
713
|
+
return chunk2OTEFUER_cjs.slash(url.fileURLToPath(undefined("@mastra/deployer/server")));
|
|
678
714
|
}
|
|
679
715
|
if (id === "#mastra") {
|
|
680
716
|
return normalizedMastraEntry;
|
|
@@ -699,7 +735,8 @@ function getInputPlugins({ entry, isVirtualFile }, mastraEntry, { sourcemapEnabl
|
|
|
699
735
|
return plugins;
|
|
700
736
|
}
|
|
701
737
|
async function captureDependenciesToOptimize(output, workspaceMap, projectRoot, initialDepsToOptimize, {
|
|
702
|
-
logger: logger$1
|
|
738
|
+
logger: logger$1,
|
|
739
|
+
shouldCheckTransitiveDependencies
|
|
703
740
|
}) {
|
|
704
741
|
const depsToOptimize = /* @__PURE__ */ new Map();
|
|
705
742
|
if (!output.facadeModuleId) {
|
|
@@ -709,21 +746,25 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
709
746
|
}
|
|
710
747
|
let entryRootPath = projectRoot;
|
|
711
748
|
if (!output.facadeModuleId.startsWith("\0virtual:")) {
|
|
712
|
-
entryRootPath = await getPackageRootPath(output.facadeModuleId) || projectRoot;
|
|
749
|
+
entryRootPath = await chunk2OTEFUER_cjs.getPackageRootPath(output.facadeModuleId) || projectRoot;
|
|
713
750
|
}
|
|
714
751
|
for (const [dependency, bindings] of Object.entries(output.importedBindings)) {
|
|
715
|
-
if (isNodeBuiltin(dependency) ||
|
|
752
|
+
if (isNodeBuiltin(dependency) || dependency.startsWith("#")) {
|
|
716
753
|
continue;
|
|
717
754
|
}
|
|
718
|
-
const pkgName = getPackageName(dependency);
|
|
755
|
+
const pkgName = chunk2OTEFUER_cjs.getPackageName(dependency);
|
|
719
756
|
let rootPath = null;
|
|
720
757
|
let isWorkspace = false;
|
|
721
758
|
if (pkgName) {
|
|
722
|
-
rootPath = await getPackageRootPath(dependency, entryRootPath);
|
|
759
|
+
rootPath = await chunk2OTEFUER_cjs.getPackageRootPath(dependency, entryRootPath);
|
|
723
760
|
isWorkspace = workspaceMap.has(pkgName);
|
|
724
761
|
}
|
|
725
|
-
const normalizedRootPath = rootPath ? slash(rootPath) : null;
|
|
726
|
-
depsToOptimize.set(dependency, {
|
|
762
|
+
const normalizedRootPath = rootPath ? chunk2OTEFUER_cjs.slash(rootPath) : null;
|
|
763
|
+
depsToOptimize.set(dependency, {
|
|
764
|
+
exports: bindings,
|
|
765
|
+
rootPath: normalizedRootPath,
|
|
766
|
+
isWorkspace
|
|
767
|
+
});
|
|
727
768
|
}
|
|
728
769
|
async function checkTransitiveDependencies(internalMap, maxDepth = 10, currentDepth = 0) {
|
|
729
770
|
if (currentDepth >= maxDepth) {
|
|
@@ -767,12 +808,18 @@ async function captureDependenciesToOptimize(output, workspaceMap, projectRoot,
|
|
|
767
808
|
await checkTransitiveDependencies(internalMap, maxDepth, currentDepth + 1);
|
|
768
809
|
}
|
|
769
810
|
}
|
|
770
|
-
|
|
811
|
+
if (shouldCheckTransitiveDependencies) {
|
|
812
|
+
await checkTransitiveDependencies(initialDepsToOptimize);
|
|
813
|
+
}
|
|
771
814
|
const dynamicImports = output.dynamicImports.filter((d) => !DEPS_TO_IGNORE.includes(d));
|
|
772
815
|
if (dynamicImports.length) {
|
|
773
816
|
for (const dynamicImport of dynamicImports) {
|
|
774
817
|
if (!depsToOptimize.has(dynamicImport) && !isNodeBuiltin(dynamicImport)) {
|
|
775
|
-
depsToOptimize.set(dynamicImport, {
|
|
818
|
+
depsToOptimize.set(dynamicImport, {
|
|
819
|
+
exports: ["*"],
|
|
820
|
+
rootPath: null,
|
|
821
|
+
isWorkspace: false
|
|
822
|
+
});
|
|
776
823
|
}
|
|
777
824
|
}
|
|
778
825
|
}
|
|
@@ -786,8 +833,9 @@ async function analyzeEntry({
|
|
|
786
833
|
sourcemapEnabled,
|
|
787
834
|
workspaceMap,
|
|
788
835
|
projectRoot,
|
|
789
|
-
initialDepsToOptimize = /* @__PURE__ */ new Map()
|
|
836
|
+
initialDepsToOptimize = /* @__PURE__ */ new Map(),
|
|
790
837
|
// used to avoid infinite recursion
|
|
838
|
+
shouldCheckTransitiveDependencies = false
|
|
791
839
|
}) {
|
|
792
840
|
const optimizerBundler = await rollup.rollup({
|
|
793
841
|
logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
|
|
@@ -808,7 +856,8 @@ async function analyzeEntry({
|
|
|
808
856
|
projectRoot,
|
|
809
857
|
initialDepsToOptimize,
|
|
810
858
|
{
|
|
811
|
-
logger
|
|
859
|
+
logger,
|
|
860
|
+
shouldCheckTransitiveDependencies
|
|
812
861
|
}
|
|
813
862
|
);
|
|
814
863
|
return {
|
|
@@ -819,6 +868,27 @@ async function analyzeEntry({
|
|
|
819
868
|
}
|
|
820
869
|
};
|
|
821
870
|
}
|
|
871
|
+
var FilenameDeclarationRegex = /(?:const|let|var)\s+__filename/;
|
|
872
|
+
var DirnameDeclarationRegex = /(?:const|let|var)\s+__dirname/;
|
|
873
|
+
function esmShim() {
|
|
874
|
+
const original = originalEsmShim__default.default();
|
|
875
|
+
return {
|
|
876
|
+
name: "esm-shim",
|
|
877
|
+
renderChunk(code, chunk, opts, meta) {
|
|
878
|
+
const hasFilename = code.includes("__filename");
|
|
879
|
+
const hasDirname = code.includes("__dirname");
|
|
880
|
+
const userDeclaredFilename = hasFilename && FilenameDeclarationRegex.test(code);
|
|
881
|
+
const userDeclaredDirname = hasDirname && DirnameDeclarationRegex.test(code);
|
|
882
|
+
if (userDeclaredFilename || userDeclaredDirname) {
|
|
883
|
+
return null;
|
|
884
|
+
}
|
|
885
|
+
if (typeof original.renderChunk === "function") {
|
|
886
|
+
return original.renderChunk.call(this, code, chunk, opts, meta);
|
|
887
|
+
}
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
}
|
|
822
892
|
function aliasHono() {
|
|
823
893
|
return {
|
|
824
894
|
name: "hono-alias",
|
|
@@ -831,8 +901,116 @@ function aliasHono() {
|
|
|
831
901
|
}
|
|
832
902
|
};
|
|
833
903
|
}
|
|
904
|
+
function nodeGypDetector() {
|
|
905
|
+
const modulesToTrack = /* @__PURE__ */ new Set();
|
|
906
|
+
const modulesToTrackPackageInfo = /* @__PURE__ */ new Map();
|
|
907
|
+
return {
|
|
908
|
+
name: "node-gyp-build-detector",
|
|
909
|
+
moduleParsed(info) {
|
|
910
|
+
if (!info.meta?.commonjs?.requires?.length) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
const hasNodeGypBuild = info.meta.commonjs.requires.some(
|
|
914
|
+
(m) => m?.resolved?.id.endsWith("node-gyp-build/index.js")
|
|
915
|
+
);
|
|
916
|
+
if (!hasNodeGypBuild) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
modulesToTrack.add(info.id);
|
|
920
|
+
modulesToTrackPackageInfo.set(info.id, localPkg.getPackageInfo(info.id));
|
|
921
|
+
},
|
|
922
|
+
async generateBundle(options, bundle) {
|
|
923
|
+
const binaryMapByChunk = /* @__PURE__ */ new Map();
|
|
924
|
+
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
925
|
+
if (chunk.type === "chunk") {
|
|
926
|
+
for (const moduleId of chunk.moduleIds) {
|
|
927
|
+
if (modulesToTrackPackageInfo.has(moduleId)) {
|
|
928
|
+
const pkgInfo = await modulesToTrackPackageInfo.get(moduleId);
|
|
929
|
+
if (!binaryMapByChunk.has(fileName)) {
|
|
930
|
+
binaryMapByChunk.set(fileName, /* @__PURE__ */ new Set());
|
|
931
|
+
}
|
|
932
|
+
if (pkgInfo?.packageJson?.name) {
|
|
933
|
+
binaryMapByChunk.get(fileName).add(pkgInfo.packageJson.name);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
const binaryMapJson = Object.fromEntries(
|
|
940
|
+
Array.from(binaryMapByChunk.entries()).map(([key, value]) => [key, Array.from(value)])
|
|
941
|
+
);
|
|
942
|
+
this.emitFile({
|
|
943
|
+
type: "asset",
|
|
944
|
+
name: "binary-map.json",
|
|
945
|
+
source: `${JSON.stringify(binaryMapJson, null, 2)}`
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// src/build/plugins/subpath-externals-resolver.ts
|
|
952
|
+
function subpathExternalsResolver(externals) {
|
|
953
|
+
return {
|
|
954
|
+
name: "subpath-externals-resolver",
|
|
955
|
+
resolveId(id) {
|
|
956
|
+
if (id.startsWith(".") || id.startsWith("/")) {
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
const isPartOfExternals = externals.some((external) => chunk2OTEFUER_cjs.isDependencyPartOfPackage(id, external));
|
|
960
|
+
if (isPartOfExternals) {
|
|
961
|
+
return {
|
|
962
|
+
id,
|
|
963
|
+
external: true
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
function moduleResolveMap(externals, projectRoot) {
|
|
970
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
971
|
+
return {
|
|
972
|
+
name: "module-resolve-map",
|
|
973
|
+
moduleParsed(info) {
|
|
974
|
+
if (info.importedIds.length === 0 || !info.id) {
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
for (const importedId of info.importedIds) {
|
|
978
|
+
for (const external of externals) {
|
|
979
|
+
if (chunk2OTEFUER_cjs.isDependencyPartOfPackage(importedId, external)) {
|
|
980
|
+
importMap.set(external, info.id);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
async generateBundle(options, bundle) {
|
|
986
|
+
const resolveMap = /* @__PURE__ */ new Map();
|
|
987
|
+
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
988
|
+
if (chunk.type === "chunk") {
|
|
989
|
+
for (const [external, resolvedFrom] of importMap) {
|
|
990
|
+
if (chunk.moduleIds.includes(resolvedFrom)) {
|
|
991
|
+
const fullPath = url.pathToFileURL(chunk2OTEFUER_cjs.slash(path2.join(projectRoot, fileName))).toString();
|
|
992
|
+
const innerMap = resolveMap.get(fullPath) || /* @__PURE__ */ new Map();
|
|
993
|
+
innerMap.set(external, url.pathToFileURL(chunk2OTEFUER_cjs.slash(resolvedFrom)).toString());
|
|
994
|
+
resolveMap.set(fullPath, innerMap);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
const resolveMapJson = Object.fromEntries(
|
|
1000
|
+
Array.from(resolveMap.entries()).map(([key, value]) => [key, Object.fromEntries(value.entries())])
|
|
1001
|
+
);
|
|
1002
|
+
this.emitFile({
|
|
1003
|
+
type: "asset",
|
|
1004
|
+
name: "module-resolve-map.json",
|
|
1005
|
+
source: `${JSON.stringify(resolveMapJson, null, 2)}`
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// src/build/analyze/bundleExternals.ts
|
|
834
1012
|
function prepareEntryFileName(name, rootDir) {
|
|
835
|
-
return rollupSafeName(name, rootDir);
|
|
1013
|
+
return chunk2OTEFUER_cjs.rollupSafeName(name, rootDir);
|
|
836
1014
|
}
|
|
837
1015
|
function createVirtualDependencies(depsToOptimize, {
|
|
838
1016
|
projectRoot,
|
|
@@ -882,7 +1060,7 @@ function createVirtualDependencies(depsToOptimize, {
|
|
|
882
1060
|
continue;
|
|
883
1061
|
}
|
|
884
1062
|
const fileName = posix.basename(currentDepPath.name);
|
|
885
|
-
const entryName = prepareEntryFileName(getCompiledDepCachePath(rootPath, fileName), rootDir);
|
|
1063
|
+
const entryName = prepareEntryFileName(chunk2OTEFUER_cjs.getCompiledDepCachePath(rootPath, fileName), rootDir);
|
|
886
1064
|
fileNameToDependencyMap.set(entryName, dep);
|
|
887
1065
|
optimizedDependencyEntries.set(dep, {
|
|
888
1066
|
...currentDepPath,
|
|
@@ -896,13 +1074,14 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
896
1074
|
transpilePackages,
|
|
897
1075
|
workspaceMap,
|
|
898
1076
|
bundlerOptions,
|
|
899
|
-
rootDir
|
|
1077
|
+
rootDir,
|
|
1078
|
+
externals
|
|
900
1079
|
}) {
|
|
901
1080
|
const transpilePackagesMap = /* @__PURE__ */ new Map();
|
|
902
1081
|
for (const pkg2 of transpilePackages) {
|
|
903
|
-
const dir = await getPackageRootPath(pkg2);
|
|
1082
|
+
const dir = await chunk2OTEFUER_cjs.getPackageRootPath(pkg2);
|
|
904
1083
|
if (dir) {
|
|
905
|
-
transpilePackagesMap.set(pkg2, slash(dir));
|
|
1084
|
+
transpilePackagesMap.set(pkg2, chunk2OTEFUER_cjs.slash(dir));
|
|
906
1085
|
} else {
|
|
907
1086
|
transpilePackagesMap.set(pkg2, workspaceMap.get(pkg2)?.location ?? pkg2);
|
|
908
1087
|
}
|
|
@@ -917,6 +1096,7 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
917
1096
|
{}
|
|
918
1097
|
)
|
|
919
1098
|
),
|
|
1099
|
+
subpathExternalsResolver(externals),
|
|
920
1100
|
transpilePackagesMap.size ? esbuild({
|
|
921
1101
|
format: "esm",
|
|
922
1102
|
include: [...transpilePackagesMap.values()].map((p) => {
|
|
@@ -945,7 +1125,8 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
945
1125
|
if (!resolvedPath) {
|
|
946
1126
|
resolvedPath = pkgJson.main ?? "index.js";
|
|
947
1127
|
}
|
|
948
|
-
|
|
1128
|
+
const resolved = await this.resolve(path2__namespace.posix.join(packageRootPath, resolvedPath), importer, options);
|
|
1129
|
+
return resolved;
|
|
949
1130
|
}
|
|
950
1131
|
} : null,
|
|
951
1132
|
rollupPlugin.optimizeLodashImports({
|
|
@@ -960,10 +1141,12 @@ async function getInputPlugins2(virtualDependencies, {
|
|
|
960
1141
|
preferBuiltins: true,
|
|
961
1142
|
exportConditions: ["node"]
|
|
962
1143
|
}),
|
|
963
|
-
bundlerOptions.isDev ?
|
|
1144
|
+
bundlerOptions.isDev ? esmShim() : null,
|
|
964
1145
|
// hono is imported from deployer, so we need to resolve from here instead of the project root
|
|
965
1146
|
aliasHono(),
|
|
966
1147
|
json__default.default(),
|
|
1148
|
+
nodeGypDetector(),
|
|
1149
|
+
moduleResolveMap(externals, rootDir),
|
|
967
1150
|
{
|
|
968
1151
|
name: "not-found-resolver",
|
|
969
1152
|
resolveId: {
|
|
@@ -1021,12 +1204,13 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1021
1204
|
{}
|
|
1022
1205
|
),
|
|
1023
1206
|
external: externals,
|
|
1024
|
-
treeshake: "safest",
|
|
1207
|
+
treeshake: bundlerOptions.isDev ? false : "safest",
|
|
1025
1208
|
plugins: getInputPlugins2(virtualDependencies, {
|
|
1026
1209
|
transpilePackages: packagesToTranspile,
|
|
1027
1210
|
workspaceMap,
|
|
1028
1211
|
bundlerOptions,
|
|
1029
|
-
rootDir
|
|
1212
|
+
rootDir,
|
|
1213
|
+
externals
|
|
1030
1214
|
})
|
|
1031
1215
|
});
|
|
1032
1216
|
const outputDirRelative = prepareEntryFileName(outputDir, rootDir);
|
|
@@ -1034,6 +1218,8 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1034
1218
|
format: "esm",
|
|
1035
1219
|
dir: rootDir,
|
|
1036
1220
|
entryFileNames: "[name].mjs",
|
|
1221
|
+
// used to get the filename of the actual error
|
|
1222
|
+
sourcemap: true,
|
|
1037
1223
|
/**
|
|
1038
1224
|
* Rollup creates chunks for common dependencies, but these chunks are by default written to the root directory instead of respecting the entryFileNames structure.
|
|
1039
1225
|
* So we want to write them to the `.mastra/output` folder as well.
|
|
@@ -1042,9 +1228,9 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1042
1228
|
if (bundlerOptions.isDev) {
|
|
1043
1229
|
const importedFromPackages = /* @__PURE__ */ new Set();
|
|
1044
1230
|
for (const moduleId of chunkInfo.moduleIds) {
|
|
1045
|
-
const normalized = slash(moduleId);
|
|
1231
|
+
const normalized = chunk2OTEFUER_cjs.slash(moduleId);
|
|
1046
1232
|
for (const [pkgName, pkgInfo] of workspaceMap.entries()) {
|
|
1047
|
-
const location = slash(pkgInfo.location);
|
|
1233
|
+
const location = chunk2OTEFUER_cjs.slash(pkgInfo.location);
|
|
1048
1234
|
if (normalized.startsWith(location)) {
|
|
1049
1235
|
importedFromPackages.add(pkgName);
|
|
1050
1236
|
break;
|
|
@@ -1066,11 +1252,12 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1066
1252
|
if (importedFromPackages.size === 1) {
|
|
1067
1253
|
const [pkgName] = importedFromPackages;
|
|
1068
1254
|
const workspaceLocation = workspaceMap.get(pkgName).location;
|
|
1069
|
-
return prepareEntryFileName(getCompiledDepCachePath(workspaceLocation, "[name].mjs"), rootDir);
|
|
1255
|
+
return prepareEntryFileName(chunk2OTEFUER_cjs.getCompiledDepCachePath(workspaceLocation, "[name].mjs"), rootDir);
|
|
1070
1256
|
}
|
|
1071
1257
|
}
|
|
1072
1258
|
return `${outputDirRelative}/[name].mjs`;
|
|
1073
1259
|
},
|
|
1260
|
+
assetFileNames: `${outputDirRelative}/[name][extname]`,
|
|
1074
1261
|
hoistTransitiveImports: false
|
|
1075
1262
|
});
|
|
1076
1263
|
await bundler.close();
|
|
@@ -1079,7 +1266,7 @@ async function buildExternalDependencies(virtualDependencies, {
|
|
|
1079
1266
|
function findExternalImporter(module, external, allOutputs) {
|
|
1080
1267
|
const capturedFiles = /* @__PURE__ */ new Set();
|
|
1081
1268
|
for (const id of module.imports) {
|
|
1082
|
-
if (id
|
|
1269
|
+
if (chunk2OTEFUER_cjs.isDependencyPartOfPackage(id, external)) {
|
|
1083
1270
|
return module;
|
|
1084
1271
|
} else {
|
|
1085
1272
|
if (id.endsWith(".mjs")) {
|
|
@@ -1125,7 +1312,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1125
1312
|
isDev
|
|
1126
1313
|
}
|
|
1127
1314
|
});
|
|
1128
|
-
const
|
|
1315
|
+
const moduleResolveMap2 = /* @__PURE__ */ new Map();
|
|
1129
1316
|
const filteredChunks = output.filter((o) => o.type === "chunk");
|
|
1130
1317
|
for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
|
|
1131
1318
|
for (const external of allExternals) {
|
|
@@ -1135,10 +1322,10 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1135
1322
|
const importer = findExternalImporter(o, external, filteredChunks);
|
|
1136
1323
|
if (importer) {
|
|
1137
1324
|
const fullPath = path2__namespace.join(workspaceRoot || projectRoot, importer.fileName);
|
|
1138
|
-
let innerMap =
|
|
1325
|
+
let innerMap = moduleResolveMap2.get(fullPath);
|
|
1139
1326
|
if (!innerMap) {
|
|
1140
1327
|
innerMap = /* @__PURE__ */ new Map();
|
|
1141
|
-
|
|
1328
|
+
moduleResolveMap2.set(fullPath, innerMap);
|
|
1142
1329
|
}
|
|
1143
1330
|
if (importer.moduleIds.length) {
|
|
1144
1331
|
innerMap.set(
|
|
@@ -1150,7 +1337,7 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1150
1337
|
}
|
|
1151
1338
|
}
|
|
1152
1339
|
const usedExternals = /* @__PURE__ */ Object.create(null);
|
|
1153
|
-
for (const [fullPath, innerMap] of
|
|
1340
|
+
for (const [fullPath, innerMap] of moduleResolveMap2) {
|
|
1154
1341
|
const innerObj = /* @__PURE__ */ Object.create(null);
|
|
1155
1342
|
for (const [external, value] of innerMap) {
|
|
1156
1343
|
innerObj[external] = value;
|
|
@@ -1159,6 +1346,108 @@ async function bundleExternals(depsToOptimize, outputDir, options) {
|
|
|
1159
1346
|
}
|
|
1160
1347
|
return { output, fileNameToDependencyMap, usedExternals };
|
|
1161
1348
|
}
|
|
1349
|
+
|
|
1350
|
+
// ../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js
|
|
1351
|
+
var UNKNOWN_FUNCTION = "<unknown>";
|
|
1352
|
+
function parse(stackString) {
|
|
1353
|
+
var lines = stackString.split("\n");
|
|
1354
|
+
return lines.reduce(function(stack, line) {
|
|
1355
|
+
var parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
|
|
1356
|
+
if (parseResult) {
|
|
1357
|
+
stack.push(parseResult);
|
|
1358
|
+
}
|
|
1359
|
+
return stack;
|
|
1360
|
+
}, []);
|
|
1361
|
+
}
|
|
1362
|
+
var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|rsc|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
1363
|
+
var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
|
1364
|
+
function parseChrome(line) {
|
|
1365
|
+
var parts = chromeRe.exec(line);
|
|
1366
|
+
if (!parts) {
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
var isNative = parts[2] && parts[2].indexOf("native") === 0;
|
|
1370
|
+
var isEval = parts[2] && parts[2].indexOf("eval") === 0;
|
|
1371
|
+
var submatch = chromeEvalRe.exec(parts[2]);
|
|
1372
|
+
if (isEval && submatch != null) {
|
|
1373
|
+
parts[2] = submatch[1];
|
|
1374
|
+
parts[3] = submatch[2];
|
|
1375
|
+
parts[4] = submatch[3];
|
|
1376
|
+
}
|
|
1377
|
+
return {
|
|
1378
|
+
file: !isNative ? parts[2] : null,
|
|
1379
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1380
|
+
arguments: isNative ? [parts[2]] : [],
|
|
1381
|
+
lineNumber: parts[3] ? +parts[3] : null,
|
|
1382
|
+
column: parts[4] ? +parts[4] : null
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|rsc|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1386
|
+
function parseWinjs(line) {
|
|
1387
|
+
var parts = winjsRe.exec(line);
|
|
1388
|
+
if (!parts) {
|
|
1389
|
+
return null;
|
|
1390
|
+
}
|
|
1391
|
+
return {
|
|
1392
|
+
file: parts[2],
|
|
1393
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1394
|
+
arguments: [],
|
|
1395
|
+
lineNumber: +parts[3],
|
|
1396
|
+
column: parts[4] ? +parts[4] : null
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|rsc|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
1400
|
+
var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
1401
|
+
function parseGecko(line) {
|
|
1402
|
+
var parts = geckoRe.exec(line);
|
|
1403
|
+
if (!parts) {
|
|
1404
|
+
return null;
|
|
1405
|
+
}
|
|
1406
|
+
var isEval = parts[3] && parts[3].indexOf(" > eval") > -1;
|
|
1407
|
+
var submatch = geckoEvalRe.exec(parts[3]);
|
|
1408
|
+
if (isEval && submatch != null) {
|
|
1409
|
+
parts[3] = submatch[1];
|
|
1410
|
+
parts[4] = submatch[2];
|
|
1411
|
+
parts[5] = null;
|
|
1412
|
+
}
|
|
1413
|
+
return {
|
|
1414
|
+
file: parts[3],
|
|
1415
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1416
|
+
arguments: parts[2] ? parts[2].split(",") : [],
|
|
1417
|
+
lineNumber: parts[4] ? +parts[4] : null,
|
|
1418
|
+
column: parts[5] ? +parts[5] : null
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
var javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
|
|
1422
|
+
function parseJSC(line) {
|
|
1423
|
+
var parts = javaScriptCoreRe.exec(line);
|
|
1424
|
+
if (!parts) {
|
|
1425
|
+
return null;
|
|
1426
|
+
}
|
|
1427
|
+
return {
|
|
1428
|
+
file: parts[3],
|
|
1429
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1430
|
+
arguments: [],
|
|
1431
|
+
lineNumber: +parts[4],
|
|
1432
|
+
column: parts[5] ? +parts[5] : null
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
var nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1436
|
+
function parseNode(line) {
|
|
1437
|
+
var parts = nodeRe.exec(line);
|
|
1438
|
+
if (!parts) {
|
|
1439
|
+
return null;
|
|
1440
|
+
}
|
|
1441
|
+
return {
|
|
1442
|
+
file: parts[2],
|
|
1443
|
+
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1444
|
+
arguments: [],
|
|
1445
|
+
lineNumber: +parts[3],
|
|
1446
|
+
column: parts[4] ? +parts[4] : null
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
// src/build/analyze.ts
|
|
1162
1451
|
function throwExternalDependencyError({
|
|
1163
1452
|
errorId,
|
|
1164
1453
|
moduleName,
|
|
@@ -1182,6 +1471,110 @@ export const mastra = new Mastra({
|
|
|
1182
1471
|
})`
|
|
1183
1472
|
});
|
|
1184
1473
|
}
|
|
1474
|
+
function getPackageNameFromBundledModuleName(moduleName) {
|
|
1475
|
+
const chunks = moduleName.split("-");
|
|
1476
|
+
if (!chunks.length) {
|
|
1477
|
+
return moduleName;
|
|
1478
|
+
}
|
|
1479
|
+
if (chunks[0]?.startsWith("@")) {
|
|
1480
|
+
return chunks.slice(0, 2).join("/");
|
|
1481
|
+
}
|
|
1482
|
+
return chunks[0];
|
|
1483
|
+
}
|
|
1484
|
+
function validateError(err, file, {
|
|
1485
|
+
binaryMapData,
|
|
1486
|
+
workspaceMap
|
|
1487
|
+
}) {
|
|
1488
|
+
let moduleName = null;
|
|
1489
|
+
let errorConfig = null;
|
|
1490
|
+
if (err instanceof ValidationError) {
|
|
1491
|
+
const parsedStack = parse(err.stack);
|
|
1492
|
+
if (err.type === "TypeError") {
|
|
1493
|
+
const pkgNameRegex = /.*node_modules\/([^\/]+)\//;
|
|
1494
|
+
const stacktraceFrame = parsedStack.find((frame) => frame.file && pkgNameRegex.test(frame.file));
|
|
1495
|
+
if (stacktraceFrame) {
|
|
1496
|
+
const match = stacktraceFrame.file.match(pkgNameRegex);
|
|
1497
|
+
moduleName = match?.[1] ?? getPackageNameFromBundledModuleName(path2.basename(file.name));
|
|
1498
|
+
} else {
|
|
1499
|
+
moduleName = getPackageNameFromBundledModuleName(path2.basename(file.name));
|
|
1500
|
+
}
|
|
1501
|
+
errorConfig = {
|
|
1502
|
+
id: "DEPLOYER_ANALYZE_TYPE_ERROR",
|
|
1503
|
+
messagePrefix: `Mastra wasn't able to bundle "${moduleName}", might be an older commonJS module. Please add`
|
|
1504
|
+
};
|
|
1505
|
+
} else if (err.stack?.includes?.("[ERR_MODULE_NOT_FOUND]")) {
|
|
1506
|
+
moduleName = err.message.match(/Cannot find package '([^']+)'/)?.[1];
|
|
1507
|
+
const parentModuleName = getPackageNameFromBundledModuleName(path2.basename(file.name));
|
|
1508
|
+
errorConfig = {
|
|
1509
|
+
id: "DEPLOYER_ANALYZE_MODULE_NOT_FOUND",
|
|
1510
|
+
messagePrefix: `Mastra wasn't able to build your project, We couldn't load "${moduleName}" from "${parentModuleName}". Make sure "${moduleName}" is installed or add`
|
|
1511
|
+
};
|
|
1512
|
+
if (moduleName === parentModuleName) {
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
if (err.message.includes("No native build was found")) {
|
|
1518
|
+
const pkgName = getPackageNameFromBundledModuleName(path2.basename(file.name));
|
|
1519
|
+
moduleName = binaryMapData[file.fileName]?.[0] ?? pkgName;
|
|
1520
|
+
errorConfig = {
|
|
1521
|
+
id: "DEPLOYER_ANALYZE_MISSING_NATIVE_BUILD",
|
|
1522
|
+
messagePrefix: "We found a binary dependency in your bundle but we cannot bundle it yet. Please add"
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
if (moduleName && workspaceMap.has(moduleName)) {
|
|
1526
|
+
throw new error.MastraError({
|
|
1527
|
+
id: "DEPLOYER_ANALYZE_ERROR_IN_WORKSPACE",
|
|
1528
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
1529
|
+
category: error.ErrorCategory.USER,
|
|
1530
|
+
details: {
|
|
1531
|
+
// importFile: moduleName,
|
|
1532
|
+
packageName: moduleName
|
|
1533
|
+
},
|
|
1534
|
+
text: `We found an error in the ${moduleName} workspace package. Please find the offending package and fix the error.
|
|
1535
|
+
Error: ${err.stack}`
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
if (errorConfig && moduleName) {
|
|
1539
|
+
throwExternalDependencyError({
|
|
1540
|
+
errorId: errorConfig.id,
|
|
1541
|
+
moduleName,
|
|
1542
|
+
packageName: moduleName,
|
|
1543
|
+
messagePrefix: errorConfig.messagePrefix
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
async function validateFile(root, file, {
|
|
1548
|
+
binaryMapData,
|
|
1549
|
+
moduleResolveMapLocation,
|
|
1550
|
+
logger,
|
|
1551
|
+
workspaceMap
|
|
1552
|
+
}) {
|
|
1553
|
+
try {
|
|
1554
|
+
if (!file.isDynamicEntry && file.isEntry) {
|
|
1555
|
+
await validate(path2.join(root, file.fileName), {
|
|
1556
|
+
moduleResolveMapLocation,
|
|
1557
|
+
injectESMShim: false
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
} catch (err) {
|
|
1561
|
+
let errorToHandle = err;
|
|
1562
|
+
if (err instanceof ValidationError && err.type === "ReferenceError" && (err.message.startsWith("__dirname") || err.message.startsWith("__filename"))) {
|
|
1563
|
+
try {
|
|
1564
|
+
await validate(path2.join(root, file.fileName), {
|
|
1565
|
+
moduleResolveMapLocation,
|
|
1566
|
+
injectESMShim: true
|
|
1567
|
+
});
|
|
1568
|
+
errorToHandle = null;
|
|
1569
|
+
} catch (err2) {
|
|
1570
|
+
errorToHandle = err2;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
if (errorToHandle instanceof Error) {
|
|
1574
|
+
validateError(errorToHandle, file, { binaryMapData, workspaceMap });
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1185
1578
|
async function validateOutput({
|
|
1186
1579
|
output,
|
|
1187
1580
|
reverseVirtualReferenceMap,
|
|
@@ -1195,60 +1588,30 @@ async function validateOutput({
|
|
|
1195
1588
|
externalDependencies: /* @__PURE__ */ new Set(),
|
|
1196
1589
|
workspaceMap
|
|
1197
1590
|
};
|
|
1198
|
-
await promises.writeFile(path2.join(outputDir, "module-resolve-map.json"), JSON.stringify(usedExternals, null, 2));
|
|
1199
1591
|
for (const deps of Object.values(usedExternals)) {
|
|
1200
1592
|
for (const dep of Object.keys(deps)) {
|
|
1201
1593
|
result.externalDependencies.add(dep);
|
|
1202
1594
|
}
|
|
1203
1595
|
}
|
|
1596
|
+
let binaryMapData = {};
|
|
1597
|
+
if (fs.existsSync(path2.join(outputDir, "binary-map.json"))) {
|
|
1598
|
+
const binaryMap = await promises.readFile(path2.join(outputDir, "binary-map.json"), "utf-8");
|
|
1599
|
+
binaryMapData = JSON.parse(binaryMap);
|
|
1600
|
+
}
|
|
1204
1601
|
for (const file of output) {
|
|
1205
1602
|
if (file.type === "asset") {
|
|
1206
1603
|
continue;
|
|
1207
1604
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
|
|
1212
|
-
}
|
|
1213
|
-
if (!file.isDynamicEntry && file.isEntry) {
|
|
1214
|
-
await validate(path2.join(projectRoot, file.fileName));
|
|
1215
|
-
}
|
|
1216
|
-
} catch (err) {
|
|
1217
|
-
if (err instanceof Error) {
|
|
1218
|
-
let moduleName = null;
|
|
1219
|
-
let errorConfig = null;
|
|
1220
|
-
if (err.message.includes("[ERR_MODULE_NOT_FOUND]")) {
|
|
1221
|
-
const moduleIdName = file.moduleIds.length >= 2 ? file.moduleIds[file.moduleIds.length - 2] : void 0;
|
|
1222
|
-
const fallbackName = file.name.split("/").pop();
|
|
1223
|
-
moduleName = moduleIdName ?? fallbackName;
|
|
1224
|
-
errorConfig = {
|
|
1225
|
-
id: "DEPLOYER_ANALYZE_MODULE_NOT_FOUND",
|
|
1226
|
-
messagePrefix: "Mastra wasn't able to build your project. Please add"
|
|
1227
|
-
};
|
|
1228
|
-
} else if (err.message.includes("Error: No native build was found for ")) {
|
|
1229
|
-
moduleName = findNativePackageModule(file.moduleIds);
|
|
1230
|
-
errorConfig = {
|
|
1231
|
-
id: "DEPLOYER_ANALYZE_MISSING_NATIVE_BUILD",
|
|
1232
|
-
messagePrefix: "We found a binary dependency in your bundle. Please add"
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
if (moduleName && errorConfig) {
|
|
1236
|
-
const pkgInfo = await localPkg.getPackageInfo(moduleName);
|
|
1237
|
-
const packageName = pkgInfo?.packageJson?.name;
|
|
1238
|
-
if (packageName) {
|
|
1239
|
-
throwExternalDependencyError({
|
|
1240
|
-
errorId: errorConfig.id,
|
|
1241
|
-
moduleName,
|
|
1242
|
-
packageName,
|
|
1243
|
-
messagePrefix: errorConfig.messagePrefix
|
|
1244
|
-
});
|
|
1245
|
-
} else {
|
|
1246
|
-
logger.debug(`Could not determine the module name for file ${file.fileName}`);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
logger.debug(`Error while validating module ${file.fileName}: ${err.message}`);
|
|
1250
|
-
}
|
|
1605
|
+
logger.debug(`Validating if ${file.fileName} is a valid module.`);
|
|
1606
|
+
if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
|
|
1607
|
+
result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
|
|
1251
1608
|
}
|
|
1609
|
+
await validateFile(projectRoot, file, {
|
|
1610
|
+
binaryMapData,
|
|
1611
|
+
moduleResolveMapLocation: path2.join(outputDir, "module-resolve-map.json"),
|
|
1612
|
+
logger,
|
|
1613
|
+
workspaceMap
|
|
1614
|
+
});
|
|
1252
1615
|
}
|
|
1253
1616
|
return result;
|
|
1254
1617
|
}
|
|
@@ -1280,17 +1643,26 @@ If you think your configuration is valid, please open an issue.`);
|
|
|
1280
1643
|
const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: mastraEntry });
|
|
1281
1644
|
let index = 0;
|
|
1282
1645
|
const depsToOptimize = /* @__PURE__ */ new Map();
|
|
1646
|
+
const { externals: customExternals = [] } = bundlerOptions || {};
|
|
1647
|
+
const allExternals = [...GLOBAL_EXTERNALS, ...customExternals];
|
|
1283
1648
|
logger.info("Analyzing dependencies...");
|
|
1649
|
+
const allUsedExternals = /* @__PURE__ */ new Set();
|
|
1284
1650
|
for (const entry of entries) {
|
|
1285
1651
|
const isVirtualFile = entry.includes("\n") || !fs.existsSync(entry);
|
|
1286
1652
|
const analyzeResult = await analyzeEntry({ entry, isVirtualFile }, mastraEntry, {
|
|
1287
1653
|
logger,
|
|
1288
1654
|
sourcemapEnabled: bundlerOptions?.sourcemap ?? false,
|
|
1289
1655
|
workspaceMap,
|
|
1290
|
-
projectRoot
|
|
1656
|
+
projectRoot,
|
|
1657
|
+
shouldCheckTransitiveDependencies: isDev
|
|
1291
1658
|
});
|
|
1292
1659
|
await promises.writeFile(path2.join(outputDir, `entry-${index++}.mjs`), analyzeResult.output.code);
|
|
1293
1660
|
for (const [dep, metadata] of analyzeResult.dependencies.entries()) {
|
|
1661
|
+
const isPartOfExternals = allExternals.some((external) => chunk2OTEFUER_cjs.isDependencyPartOfPackage(dep, external));
|
|
1662
|
+
if (isPartOfExternals) {
|
|
1663
|
+
allUsedExternals.add(dep);
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1294
1666
|
if (depsToOptimize.has(dep)) {
|
|
1295
1667
|
const existingEntry = depsToOptimize.get(dep);
|
|
1296
1668
|
depsToOptimize.set(dep, {
|
|
@@ -1309,14 +1681,13 @@ If you think your configuration is valid, please open an issue.`);
|
|
|
1309
1681
|
}
|
|
1310
1682
|
}
|
|
1311
1683
|
}
|
|
1312
|
-
|
|
1684
|
+
const sortedDeps = Array.from(depsToOptimize.keys()).sort();
|
|
1313
1685
|
logger.info("Optimizing dependencies...");
|
|
1314
|
-
logger.debug(
|
|
1315
|
-
`${Array.from(depsToOptimize.keys()).map((key) => `- ${key}`).join("\n")}`
|
|
1316
|
-
);
|
|
1686
|
+
logger.debug(`${sortedDeps.map((key) => `- ${key}`).join("\n")}`);
|
|
1317
1687
|
const { output, fileNameToDependencyMap, usedExternals } = await bundleExternals(depsToOptimize, outputDir, {
|
|
1318
1688
|
bundlerOptions: {
|
|
1319
1689
|
...bundlerOptions,
|
|
1690
|
+
externals: allExternals,
|
|
1320
1691
|
enableEsmShim,
|
|
1321
1692
|
isDev
|
|
1322
1693
|
},
|
|
@@ -1335,20 +1706,22 @@ If you think your configuration is valid, please open an issue.`);
|
|
|
1335
1706
|
},
|
|
1336
1707
|
logger
|
|
1337
1708
|
);
|
|
1338
|
-
return
|
|
1709
|
+
return {
|
|
1710
|
+
...result,
|
|
1711
|
+
externalDependencies: /* @__PURE__ */ new Set([...result.externalDependencies, ...Array.from(allUsedExternals)])
|
|
1712
|
+
};
|
|
1339
1713
|
}
|
|
1340
1714
|
|
|
1341
1715
|
exports.aliasHono = aliasHono;
|
|
1342
1716
|
exports.analyzeBundle = analyzeBundle;
|
|
1343
1717
|
exports.esbuild = esbuild;
|
|
1718
|
+
exports.esmShim = esmShim;
|
|
1344
1719
|
exports.extractMastraOption = extractMastraOption;
|
|
1345
1720
|
exports.getBundlerOptions = getBundlerOptions;
|
|
1346
|
-
exports.getPackageName = getPackageName;
|
|
1347
|
-
exports.getPackageRootPath = getPackageRootPath;
|
|
1348
1721
|
exports.getWorkspaceInformation = getWorkspaceInformation;
|
|
1349
1722
|
exports.removeAllOptionsFromMastraExcept = removeAllOptionsFromMastraExcept;
|
|
1350
1723
|
exports.removeDeployer = removeDeployer2;
|
|
1351
|
-
exports.
|
|
1724
|
+
exports.subpathExternalsResolver = subpathExternalsResolver;
|
|
1352
1725
|
exports.tsConfigPaths = tsConfigPaths;
|
|
1353
|
-
//# sourceMappingURL=chunk-
|
|
1354
|
-
//# sourceMappingURL=chunk-
|
|
1726
|
+
//# sourceMappingURL=chunk-MC37X2IH.cjs.map
|
|
1727
|
+
//# sourceMappingURL=chunk-MC37X2IH.cjs.map
|