@mastra/deployer-cloudflare 1.2.10 → 1.2.11

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/index.js CHANGED
@@ -1,168 +1,188 @@
1
- import { writeFile } from 'fs/promises';
2
- import { builtinModules } from 'module';
3
- import { join, relative } from 'path';
4
- import { Deployer } from '@mastra/deployer';
5
- import virtual from '@rollup/plugin-virtual';
6
- import * as babel from '@babel/core';
7
- import { transformSync } from '@babel/core';
8
-
9
- // src/index.ts
10
- function mastraInstanceWrapper() {
11
- const exportName = "mastra";
12
- const className = "Mastra";
13
- const t = babel.types;
14
- return {
15
- name: "wrap-mastra",
16
- visitor: {
17
- ExportNamedDeclaration(path) {
18
- if (t.isVariableDeclaration(path.node?.declaration)) {
19
- for (const declaration of path.node.declaration.declarations) {
20
- if (t.isIdentifier(declaration?.id, { name: exportName }) && t.isNewExpression(declaration?.init) && t.isIdentifier(declaration.init.callee, { name: className })) {
21
- declaration.init = t.arrowFunctionExpression([], declaration.init);
22
- break;
23
- }
24
- }
25
- }
26
- }
27
- }
28
- };
1
+ import { builtinModules } from "module";
2
+ import { writeFile } from "fs/promises";
3
+ import { join, relative } from "path";
4
+ import { Deployer } from "@mastra/deployer";
5
+ import virtual from "@rollup/plugin-virtual";
6
+ import * as babel from "@babel/core";
7
+ import { transformSync } from "@babel/core";
8
+ //#region src/babel/mastra-instance-wrapper.ts
9
+ /**
10
+ * Babel plugin that transforms Mastra exports for Cloudflare Workers compatibility.
11
+ *
12
+ * This plugin:
13
+ * 1. Identifies named exports of the 'mastra' variable
14
+ * 2. Checks if the export is a new instance of the 'Mastra' class
15
+ * 3. Wraps the Mastra instantiation in an arrow function to ensure proper initialization
16
+ * in the Cloudflare Workers environment
17
+ *
18
+ * The transformation ensures the Mastra instance is properly scoped and initialized
19
+ * for each request in the Cloudflare Workers environment.
20
+ *
21
+ * @returns {PluginObject} A Babel plugin object with a visitor that performs the transformation
22
+ *
23
+ * @example
24
+ * // Before transformation:
25
+ * export const mastra = new Mastra();
26
+ *
27
+ * // After transformation:
28
+ * export const mastra = () => new Mastra();
29
+ */
30
+ function mastraInstanceWrapper$1() {
31
+ const exportName = "mastra";
32
+ const className = "Mastra";
33
+ const t = babel.types;
34
+ return {
35
+ name: "wrap-mastra",
36
+ visitor: { ExportNamedDeclaration(path) {
37
+ if (t.isVariableDeclaration(path.node?.declaration)) {
38
+ for (const declaration of path.node.declaration.declarations) if (t.isIdentifier(declaration?.id, { name: exportName }) && t.isNewExpression(declaration?.init) && t.isIdentifier(declaration.init.callee, { name: className })) {
39
+ declaration.init = t.arrowFunctionExpression([], declaration.init);
40
+ break;
41
+ }
42
+ }
43
+ } }
44
+ };
29
45
  }
30
-
31
- // src/plugins/mastra-instance-wrapper.ts
32
- function mastraInstanceWrapper2(mastraEntryFile) {
33
- return {
34
- name: "mastra-wrapper",
35
- transform(code, id) {
36
- if (id !== mastraEntryFile) {
37
- return null;
38
- }
39
- const result = transformSync(code, {
40
- filename: id,
41
- babelrc: false,
42
- configFile: false,
43
- plugins: [mastraInstanceWrapper]
44
- });
45
- if (!result?.code) {
46
- throw new Error("mastra-wrapper plugin did not return code, there is likely a bug in the plugin.");
47
- }
48
- return {
49
- code: result.code,
50
- map: result?.map
51
- };
52
- }
53
- };
46
+ //#endregion
47
+ //#region src/plugins/mastra-instance-wrapper.ts
48
+ function mastraInstanceWrapper(mastraEntryFile) {
49
+ return {
50
+ name: "mastra-wrapper",
51
+ transform(code, id) {
52
+ if (id !== mastraEntryFile) return null;
53
+ const result = transformSync(code, {
54
+ filename: id,
55
+ babelrc: false,
56
+ configFile: false,
57
+ plugins: [mastraInstanceWrapper$1]
58
+ });
59
+ if (!result?.code) throw new Error("mastra-wrapper plugin did not return code, there is likely a bug in the plugin.");
60
+ return {
61
+ code: result.code,
62
+ map: result?.map
63
+ };
64
+ }
65
+ };
54
66
  }
55
- function postgresStoreInstanceChecker() {
56
- const t = babel.types;
57
- const instances = [];
58
- return {
59
- name: "postgresstore-instance-checker",
60
- visitor: {
61
- NewExpression(path, state) {
62
- if (t.isIdentifier(path.node.callee) && path.node.callee.name === "PostgresStore") {
63
- const filename = state.file?.opts?.filename || "unknown file";
64
- const location = path.node.loc ? `${filename}: line ${path.node.loc.start.line}, column ${path.node.loc.start.column}` : "unknown location";
65
- instances.push({
66
- path,
67
- location
68
- });
69
- }
70
- }
71
- },
72
- post() {
73
- if (instances.length > 1) {
74
- const errorMessage = [
75
- `Found ${instances.length} PostgresStore instantiations:`,
76
- ...instances.map((instance, i) => ` ${i + 1}. At ${instance.location}`),
77
- "Only one PostgresStore instance should be created per Cloudflare Worker."
78
- ].join("\n");
79
- const lastInstance = instances[instances.length - 1];
80
- throw lastInstance?.path.buildCodeFrameError(errorMessage);
81
- }
82
- }
83
- };
67
+ //#endregion
68
+ //#region src/babel/postgres-store-instance-checker.ts
69
+ /**
70
+ * Babel plugin that enforces singleton PostgresStore instances in Cloudflare Workers.
71
+ *
72
+ * This plugin:
73
+ * 1. Scans for all `new PostgresStore()` instantiations
74
+ * 2. Records their file locations
75
+ * 3. Throws an error if multiple instances are found
76
+ *
77
+ * Cloudflare Workers should only create one PostgresStore instance to avoid connection
78
+ * pool exhaustion and ensure proper resource management.
79
+ *
80
+ * @returns {PluginObject} A Babel plugin object that validates PostgresStore usage
81
+ *
82
+ * @example
83
+ * // Throws error if multiple instances found:
84
+ * const store1 = new PostgresStore();
85
+ * const store2 = new PostgresStore(); // Error thrown here
86
+ */
87
+ function postgresStoreInstanceChecker$1() {
88
+ const t = babel.types;
89
+ const instances = [];
90
+ return {
91
+ name: "postgresstore-instance-checker",
92
+ visitor: { NewExpression(path, state) {
93
+ if (t.isIdentifier(path.node.callee) && path.node.callee.name === "PostgresStore") {
94
+ const filename = state.file?.opts?.filename || "unknown file";
95
+ const location = path.node.loc ? `${filename}: line ${path.node.loc.start.line}, column ${path.node.loc.start.column}` : "unknown location";
96
+ instances.push({
97
+ path,
98
+ location
99
+ });
100
+ }
101
+ } },
102
+ post() {
103
+ if (instances.length > 1) {
104
+ const errorMessage = [
105
+ `Found ${instances.length} PostgresStore instantiations:`,
106
+ ...instances.map((instance, i) => ` ${i + 1}. At ${instance.location}`),
107
+ "Only one PostgresStore instance should be created per Cloudflare Worker."
108
+ ].join("\n");
109
+ throw instances[instances.length - 1]?.path.buildCodeFrameError(errorMessage);
110
+ }
111
+ }
112
+ };
84
113
  }
85
-
86
- // src/plugins/postgres-store-instance-checker.ts
87
- function postgresStoreInstanceChecker2() {
88
- return {
89
- name: "postgres-store-instance-checker",
90
- transform(code, id) {
91
- const result = transformSync(code, {
92
- filename: id,
93
- babelrc: false,
94
- configFile: false,
95
- plugins: [postgresStoreInstanceChecker]
96
- });
97
- if (!result || typeof result.code !== "string") {
98
- return null;
99
- }
100
- return {
101
- code: result.code,
102
- map: result.map ? result.map : null
103
- };
104
- }
105
- };
114
+ //#endregion
115
+ //#region src/plugins/postgres-store-instance-checker.ts
116
+ function postgresStoreInstanceChecker() {
117
+ return {
118
+ name: "postgres-store-instance-checker",
119
+ transform(code, id) {
120
+ const result = transformSync(code, {
121
+ filename: id,
122
+ babelrc: false,
123
+ configFile: false,
124
+ plugins: [postgresStoreInstanceChecker$1]
125
+ });
126
+ if (!result || typeof result.code !== "string") return null;
127
+ return {
128
+ code: result.code,
129
+ map: result.map ? result.map : null
130
+ };
131
+ }
132
+ };
106
133
  }
107
-
108
- // src/index.ts
109
- var nodeBuiltins = new Set(builtinModules);
134
+ //#endregion
135
+ //#region src/index.ts
136
+ const nodeBuiltins = new Set(builtinModules);
137
+ /**
138
+ * Rollup plugin that marks bare Node.js builtin imports (e.g. `process`, `path`)
139
+ * as external. Cloudflare Workers with `nodejs_compat` provides these at runtime,
140
+ * so they must not be resolved to npm polyfill packages during bundling.
141
+ */
110
142
  function nodeBuiltinsExternal() {
111
- return {
112
- name: "node-builtins-external",
113
- resolveId(id) {
114
- if (nodeBuiltins.has(id)) {
115
- return { id, external: true };
116
- }
117
- return null;
118
- }
119
- };
143
+ return {
144
+ name: "node-builtins-external",
145
+ resolveId(id) {
146
+ if (nodeBuiltins.has(id)) return {
147
+ id,
148
+ external: true
149
+ };
150
+ return null;
151
+ }
152
+ };
120
153
  }
121
154
  var CloudflareDeployer = class extends Deployer {
122
- userConfig;
123
- constructor(userConfig) {
124
- super({ name: "CLOUDFLARE" });
125
- this.platform = "browser";
126
- this.userConfig = { ...userConfig };
127
- if (userConfig.workerNamespace) {
128
- console.warn("[CloudflareDeployer]: `workerNamespace` is no longer used");
129
- }
130
- if (!userConfig.name && userConfig.projectName) {
131
- this.userConfig.name = userConfig.projectName;
132
- console.warn("[CloudflareDeployer]: `projectName` is deprecated, use `name` instead");
133
- }
134
- if (!userConfig.d1_databases && userConfig.d1Databases) {
135
- this.userConfig.d1_databases = userConfig.d1Databases;
136
- console.warn("[CloudflareDeployer]: `d1Databases` is deprecated, use `d1_databases` instead");
137
- }
138
- if (!userConfig.kv_namespaces && userConfig.kvNamespaces) {
139
- this.userConfig.kv_namespaces = userConfig.kvNamespaces;
140
- console.warn("[CloudflareDeployer]: `kvNamespaces` is deprecated, use `kv_namespaces` instead");
141
- }
142
- }
143
- async writeFiles(outputDirectory) {
144
- const {
145
- vars: userVars,
146
- alias: userAlias,
147
- // Remove deprecated fields so they don't leak into wrangler.json
148
- projectName: _projectName,
149
- workerNamespace: _workerNamespace,
150
- d1Databases: _d1Databases,
151
- kvNamespaces: _kvNamespaces,
152
- ...userConfig
153
- } = this.userConfig;
154
- const loadedEnvVars = await this.loadEnvVars();
155
- const envsAsObject = Object.assign({}, userVars);
156
- if (loadedEnvVars.size > 0) {
157
- const envKeys = [...loadedEnvVars.keys()].join(", ");
158
- this.logger.warn(
159
- `Environment variables from .env (${envKeys}) were not written to wrangler.jsonc.
155
+ userConfig;
156
+ constructor(userConfig) {
157
+ super({ name: "CLOUDFLARE" });
158
+ this.platform = "browser";
159
+ this.userConfig = { ...userConfig };
160
+ if (userConfig.workerNamespace) console.warn("[CloudflareDeployer]: `workerNamespace` is no longer used");
161
+ if (!userConfig.name && userConfig.projectName) {
162
+ this.userConfig.name = userConfig.projectName;
163
+ console.warn("[CloudflareDeployer]: `projectName` is deprecated, use `name` instead");
164
+ }
165
+ if (!userConfig.d1_databases && userConfig.d1Databases) {
166
+ this.userConfig.d1_databases = userConfig.d1Databases;
167
+ console.warn("[CloudflareDeployer]: `d1Databases` is deprecated, use `d1_databases` instead");
168
+ }
169
+ if (!userConfig.kv_namespaces && userConfig.kvNamespaces) {
170
+ this.userConfig.kv_namespaces = userConfig.kvNamespaces;
171
+ console.warn("[CloudflareDeployer]: `kvNamespaces` is deprecated, use `kv_namespaces` instead");
172
+ }
173
+ }
174
+ async writeFiles(outputDirectory) {
175
+ const { vars: userVars, alias: userAlias, projectName: _projectName, workerNamespace: _workerNamespace, d1Databases: _d1Databases, kvNamespaces: _kvNamespaces, ...userConfig } = this.userConfig;
176
+ const loadedEnvVars = await this.loadEnvVars();
177
+ const envsAsObject = Object.assign({}, userVars);
178
+ if (loadedEnvVars.size > 0) {
179
+ const envKeys = [...loadedEnvVars.keys()].join(", ");
180
+ this.logger.warn(`Environment variables from .env (${envKeys}) were not written to wrangler.jsonc.
160
181
  Upload them as Cloudflare Secrets instead:
161
- npx wrangler secret bulk .env`
162
- );
163
- }
164
- const typescriptStubPath = "typescript-stub.mjs";
165
- const typescriptStub = `// Stub for TypeScript - not available at runtime in Cloudflare Workers
182
+ npx wrangler secret bulk .env`);
183
+ }
184
+ const typescriptStubPath = "typescript-stub.mjs";
185
+ await writeFile(join(outputDirectory, this.outputDir, typescriptStubPath), `// Stub for TypeScript - not available at runtime in Cloudflare Workers
166
186
  // The @mastra/agent-builder package will fall back to basic validation
167
187
  export default {};
168
188
  export const createSourceFile = () => null;
@@ -179,68 +199,72 @@ export const sys = {
179
199
  fileExists: () => false,
180
200
  readFile: () => undefined,
181
201
  };
182
- `;
183
- await writeFile(join(outputDirectory, this.outputDir, typescriptStubPath), typescriptStub);
184
- const execaStubPath = "execa-stub.mjs";
185
- const execaStub = `// Stub for execa - not available at runtime in Cloudflare Workers
202
+ `);
203
+ const execaStubPath = "execa-stub.mjs";
204
+ await writeFile(join(outputDirectory, this.outputDir, execaStubPath), `// Stub for execa - not available at runtime in Cloudflare Workers
186
205
  export const execa = () => { throw new Error('execa is not available in Cloudflare Workers'); };
187
206
  export const execaNode = execa;
188
207
  export const execaSync = execa;
189
208
  export const execaCommand = execa;
190
209
  export const execaCommandSync = execa;
191
210
  export const $ = execa;
192
- `;
193
- await writeFile(join(outputDirectory, this.outputDir, execaStubPath), execaStub);
194
- const readableStreamStubPath = "readable-stream-stub.mjs";
195
- const readableStreamStub = `// Redirect readable-stream to native node:stream (available via nodejs_compat)
211
+ `);
212
+ const readableStreamStubPath = "readable-stream-stub.mjs";
213
+ await writeFile(join(outputDirectory, this.outputDir, readableStreamStubPath), `// Redirect readable-stream to native node:stream (available via nodejs_compat)
196
214
  import stream from 'node:stream';
197
215
  export const { Readable, Writable, Duplex, Transform, PassThrough, Stream, pipeline, finished } = stream;
198
216
  export default stream;
199
- `;
200
- await writeFile(join(outputDirectory, this.outputDir, readableStreamStubPath), readableStreamStub);
201
- const wranglerConfig = {
202
- name: "mastra",
203
- compatibility_date: "2025-04-01",
204
- compatibility_flags: ["nodejs_compat", "nodejs_compat_populate_process_env"],
205
- observability: {
206
- logs: {
207
- enabled: true
208
- }
209
- },
210
- ...userConfig,
211
- main: "./index.mjs",
212
- vars: envsAsObject,
213
- // Alias stubs to prevent wrangler from bundling unavailable libraries
214
- alias: {
215
- typescript: `./${typescriptStubPath}`,
216
- execa: `./${execaStubPath}`,
217
- "readable-stream": `./${readableStreamStubPath}`,
218
- ...userAlias
219
- }
220
- };
221
- await writeFile(join(outputDirectory, this.outputDir, "wrangler.json"), JSON.stringify(wranglerConfig, null, 2));
222
- const projectRoot = join(outputDirectory, "../");
223
- const jsoncFilePath = join(projectRoot, "wrangler.jsonc");
224
- const mainFilePath = join(outputDirectory, this.outputDir, "index.mjs");
225
- const tsStubFilePath = join(outputDirectory, this.outputDir, typescriptStubPath);
226
- const wranglerJsoncConfig = {
227
- placeholder: "PLACEHOLDER",
228
- $schema: "./node_modules/wrangler/config-schema.json",
229
- ...wranglerConfig,
230
- main: `./${relative(projectRoot, mainFilePath)}`,
231
- alias: {
232
- ...wranglerConfig.alias,
233
- typescript: `./${relative(projectRoot, tsStubFilePath)}`
234
- }
235
- };
236
- const jsonc = JSON.stringify(wranglerJsoncConfig, null, 2).replace(
237
- /"placeholder": "PLACEHOLDER",/,
238
- "/* This file was auto-generated through Mastra. Edit the CloudflareDeployer() instance directly. */"
239
- );
240
- await writeFile(jsoncFilePath, jsonc);
241
- }
242
- getEntry() {
243
- return `
217
+ `);
218
+ const moduleStubPath = "module-stub.mjs";
219
+ await writeFile(join(outputDirectory, this.outputDir, moduleStubPath), `// Stub for module.createRequire in Cloudflare Workers
220
+ export function createRequire() {
221
+ const req = specifier => {
222
+ throw new Error(\`require(\${specifier}) is not available in Cloudflare Workers\`);
223
+ };
224
+ req.resolve = specifier => specifier;
225
+ return req;
226
+ }
227
+ export default { createRequire };
228
+ `);
229
+ const wranglerConfig = {
230
+ name: "mastra",
231
+ compatibility_date: "2025-04-01",
232
+ compatibility_flags: ["nodejs_compat", "nodejs_compat_populate_process_env"],
233
+ observability: { logs: { enabled: true } },
234
+ ...userConfig,
235
+ main: "./index.mjs",
236
+ vars: envsAsObject,
237
+ alias: {
238
+ typescript: `./${typescriptStubPath}`,
239
+ execa: `./${execaStubPath}`,
240
+ "readable-stream": `./${readableStreamStubPath}`,
241
+ module: `./${moduleStubPath}`,
242
+ "node:module": `./${moduleStubPath}`,
243
+ ...userAlias
244
+ }
245
+ };
246
+ await writeFile(join(outputDirectory, this.outputDir, "wrangler.json"), JSON.stringify(wranglerConfig, null, 2));
247
+ const projectRoot = join(outputDirectory, "../");
248
+ const jsoncFilePath = join(projectRoot, "wrangler.jsonc");
249
+ const mainFilePath = join(outputDirectory, this.outputDir, "index.mjs");
250
+ const tsStubFilePath = join(outputDirectory, this.outputDir, typescriptStubPath);
251
+ const moduleStubFilePath = join(outputDirectory, this.outputDir, moduleStubPath);
252
+ const wranglerJsoncConfig = {
253
+ placeholder: "PLACEHOLDER",
254
+ $schema: "./node_modules/wrangler/config-schema.json",
255
+ ...wranglerConfig,
256
+ main: `./${relative(projectRoot, mainFilePath)}`,
257
+ alias: {
258
+ ...wranglerConfig.alias,
259
+ typescript: `./${relative(projectRoot, tsStubFilePath)}`,
260
+ module: `./${relative(projectRoot, moduleStubFilePath)}`,
261
+ "node:module": `./${relative(projectRoot, moduleStubFilePath)}`
262
+ }
263
+ };
264
+ await writeFile(jsoncFilePath, JSON.stringify(wranglerJsoncConfig, null, 2).replace(/"placeholder": "PLACEHOLDER",/, "/* This file was auto-generated through Mastra. Edit the CloudflareDeployer() instance directly. */"));
265
+ }
266
+ getEntry() {
267
+ return `
244
268
  import '#polyfills';
245
269
  import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
246
270
 
@@ -255,66 +279,69 @@ export default stream;
255
279
  _mastra.__registerInternalWorkflow(scoreTracesWorkflow);
256
280
  }
257
281
 
258
- const app = await createHonoServer(_mastra, { tools: getToolExports(tools) });
282
+ const app = await createHonoServer(_mastra, { tools: getToolExports(tools), browserStream: false });
259
283
  return app.fetch(request, env, context);
260
284
  }
261
285
  }
262
286
  `;
287
+ }
288
+ async prepare(outputDirectory) {
289
+ await super.prepare(outputDirectory);
290
+ await this.writeFiles(outputDirectory);
291
+ }
292
+ async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions) {
293
+ const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {
294
+ ...bundlerOptions,
295
+ enableEsmShim: false
296
+ });
297
+ const hasPostgresStore = await this.deps.checkDependencies(["@mastra/pg"]) === `ok`;
298
+ if (Array.isArray(inputOptions.plugins)) {
299
+ inputOptions.plugins = [
300
+ nodeBuiltinsExternal(),
301
+ virtual({ "#polyfills": `
302
+ try {
303
+ if (!process.versions) {
304
+ Object.defineProperty(process, 'versions', { value: {}, configurable: true });
263
305
  }
264
- async prepare(outputDirectory) {
265
- await super.prepare(outputDirectory);
266
- await this.writeFiles(outputDirectory);
267
- }
268
- async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions) {
269
- const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {
270
- ...bundlerOptions,
271
- enableEsmShim: false
272
- });
273
- const hasPostgresStore = await this.deps.checkDependencies(["@mastra/pg"]) === `ok`;
274
- if (Array.isArray(inputOptions.plugins)) {
275
- inputOptions.plugins = [
276
- nodeBuiltinsExternal(),
277
- virtual({
278
- "#polyfills": `
279
- process.versions = process.versions || {};
280
- process.versions.node = '${process.versions.node}';
281
- `
282
- }),
283
- ...inputOptions.plugins,
284
- mastraInstanceWrapper2(mastraEntryFile)
285
- ];
286
- if (hasPostgresStore) {
287
- inputOptions.plugins.push(postgresStoreInstanceChecker2());
288
- }
289
- }
290
- return inputOptions;
291
- }
292
- async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
293
- return this._bundle(this.getEntry(), entryFile, { outputDirectory, projectRoot, enableEsmShim: false }, toolsPaths);
294
- }
295
- async deploy() {
296
- this.logger?.info("Deploying to Cloudflare failed. Please use the Cloudflare dashboard to deploy.");
297
- }
298
- /**
299
- * TODO: Remove this method in the next major version
300
- *
301
- * @deprecated
302
- */
303
- async tagWorker() {
304
- throw new Error("tagWorker method is no longer supported. Use the Cloudflare dashboard or API directly.");
305
- }
306
- async lint(entryFile, outputDirectory, toolsPaths) {
307
- await super.lint(entryFile, outputDirectory, toolsPaths);
308
- const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
309
- if (hasLibsql) {
310
- this.logger.error(
311
- "Cloudflare Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency. Please use Cloudflare D1 instead: @mastra/cloudflare-d1."
312
- );
313
- process.exit(1);
314
- }
306
+ if (!process.versions.node) {
307
+ Object.defineProperty(process.versions, 'node', { value: '${process.versions.node}', configurable: true });
315
308
  }
309
+ } catch {}
310
+ ` }),
311
+ ...inputOptions.plugins,
312
+ mastraInstanceWrapper(mastraEntryFile)
313
+ ];
314
+ if (hasPostgresStore) inputOptions.plugins.push(postgresStoreInstanceChecker());
315
+ }
316
+ return inputOptions;
317
+ }
318
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
319
+ return this._bundle(this.getEntry(), entryFile, {
320
+ outputDirectory,
321
+ projectRoot,
322
+ enableEsmShim: false
323
+ }, toolsPaths);
324
+ }
325
+ async deploy() {
326
+ this.logger?.info("Deploying to Cloudflare failed. Please use the Cloudflare dashboard to deploy.");
327
+ }
328
+ /**
329
+ * TODO: Remove this method in the next major version
330
+ *
331
+ * @deprecated
332
+ */
333
+ async tagWorker() {
334
+ throw new Error("tagWorker method is no longer supported. Use the Cloudflare dashboard or API directly.");
335
+ }
336
+ async lint(entryFile, outputDirectory, toolsPaths) {
337
+ await super.lint(entryFile, outputDirectory, toolsPaths);
338
+ if (await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`) {
339
+ this.logger.error("Cloudflare Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency. Please use Cloudflare D1 instead: @mastra/cloudflare-d1.");
340
+ process.exit(1);
341
+ }
342
+ }
316
343
  };
317
-
344
+ //#endregion
318
345
  export { CloudflareDeployer };
319
- //# sourceMappingURL=index.js.map
346
+
320
347
  //# sourceMappingURL=index.js.map