@mastra/deployer-netlify 1.2.20-alpha.0 → 1.2.20

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @mastra/deployer-netlify
2
2
 
3
+ ## 1.2.20
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`7176362`](https://github.com/mastra-ai/mastra/commit/717636281a3339911a05ea2cc8ae38afe4fd2cef), [`9045b8f`](https://github.com/mastra-ai/mastra/commit/9045b8fdf622e1d735b96ddd6500bd32556636d9), [`7677a2c`](https://github.com/mastra-ai/mastra/commit/7677a2cd47729221ca28afc5067d26e22d925b59), [`e3b796d`](https://github.com/mastra-ai/mastra/commit/e3b796d29a63f0d5c97dd815aadec40687346d70), [`f7a7467`](https://github.com/mastra-ai/mastra/commit/f7a74678193921e7ea4790232d707b3237626cac), [`bab189f`](https://github.com/mastra-ai/mastra/commit/bab189f8c04903bd66ab7e5604011485037c71bf), [`49ccd14`](https://github.com/mastra-ai/mastra/commit/49ccd142268a61fb55ea75bc76287643a21f3677), [`f9c56f3`](https://github.com/mastra-ai/mastra/commit/f9c56f336ee8c250763a438990f8e60a428353c9), [`3855b38`](https://github.com/mastra-ai/mastra/commit/3855b38c4c25af32ab8e298e148becc963abe92c)]:
8
+ - @mastra/core@1.63.0
9
+ - @mastra/deployer@1.63.0
10
+
3
11
  ## 1.2.20-alpha.0
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -98,11 +98,11 @@ var NetlifyDeployer = class extends _mastra_deployer.Deployer {
98
98
  async prepare(outputDirectory) {
99
99
  await super.prepare(outputDirectory);
100
100
  }
101
- async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions) {
101
+ async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions, additionalEntries) {
102
102
  const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {
103
103
  ...bundlerOptions,
104
104
  enableEsmShim: this.target !== "edge"
105
- });
105
+ }, additionalEntries);
106
106
  if (this.target === "edge" && Array.isArray(inputOptions.plugins)) {
107
107
  inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());
108
108
  if (Array.isArray(inputOptions.external)) inputOptions.external = inputOptions.external.filter((id) => !EDGE_INCOMPATIBLE_MODULES.includes(id));
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["builtinModules","Deployer","DepsService"],"sources":["../src/index.ts"],"sourcesContent":["import { builtinModules } from 'node:module';\nimport { join } from 'node:path';\nimport process from 'node:process';\nimport { Deployer } from '@mastra/deployer';\nimport type { analyzeBundle } from '@mastra/deployer/analyze';\nimport type { BundlerOptions } from '@mastra/deployer/bundler';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\n/** Bare Node.js built-in module names (excludes internal `_`-prefixed ones). */\nconst builtins = new Set(builtinModules.filter(m => !m.startsWith('_')));\n\n/**\n * Rollup plugin that adds the `node:` prefix to bare Node.js built-in imports.\n * Deno requires `node:events` instead of `events`, `node:fs` instead of `fs`, etc.\n */\nfunction nodeBuiltinPrefix() {\n return {\n name: 'node-builtin-prefix',\n resolveId(source: string) {\n const base = source.split('/')[0]!;\n if (builtins.has(base) && !source.startsWith('node:')) {\n return { id: `node:${source}`, external: true };\n }\n return null;\n },\n };\n}\n\n/** Modules that Netlify's Edge bundler cannot resolve: native Node addons (`bufferutil`, `utf-8-validate`) and `typescript`. */\nconst EDGE_INCOMPATIBLE_MODULES = ['bufferutil', 'utf-8-validate', 'typescript'];\n\n/**\n * Rollup plugin that replaces edge-incompatible modules with an empty stub so\n * they do not appear as external imports in the bundle.\n */\nfunction stubEdgeIncompatibleModules() {\n const stubs = new Set(EDGE_INCOMPATIBLE_MODULES);\n const STUB_ID = '\\0mastra-netlify-edge-stub';\n return {\n name: 'stub-edge-incompatible-modules',\n resolveId(source: string) {\n return stubs.has(source) ? STUB_ID : null;\n },\n load(id: string) {\n if (id === STUB_ID) {\n return 'export default undefined;';\n }\n return null;\n },\n };\n}\n\nexport interface NetlifyDeployerOptions {\n /**\n * Deploy target for Netlify.\n *\n * - `'serverless'` — Standard Netlify Functions (Node.js runtime, 60s default timeout).\n * - `'edge'` — Netlify Edge Functions (Deno-based runtime, no hard timeout, runs at the edge).\n *\n * @default 'serverless'\n */\n target?: 'serverless' | 'edge';\n}\n\nexport class NetlifyDeployer extends Deployer {\n readonly target: 'serverless' | 'edge';\n\n constructor(options: NetlifyDeployerOptions = {}) {\n super({ name: 'NETLIFY' });\n\n this.target = options.target ?? 'serverless';\n\n this.outputDir =\n this.target === 'edge' ? join('.netlify', 'v1', 'edge-functions') : join('.netlify', 'v1', 'functions', 'api');\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n if (this.target === 'edge') {\n // Edge functions run on Deno — no platform-specific architecture constraints\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n } else {\n await deps.install({\n dir: join(outputDirectory, this.outputDir),\n architecture: {\n os: ['linux'],\n cpu: ['x64'],\n libc: ['gnu'],\n },\n });\n }\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Netlify failed. Please use the Netlify dashboard to deploy.');\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n bundlerOptions: BundlerOptions,\n ) {\n const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {\n ...bundlerOptions,\n enableEsmShim: this.target !== 'edge',\n });\n\n if (this.target === 'edge' && Array.isArray(inputOptions.plugins)) {\n // Run before subpathExternalsResolver so the resolveId hooks win.\n inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());\n\n // Drop edge-incompatible modules from Rollup's external list so the stub plugin can redirect them.\n if (Array.isArray(inputOptions.external)) {\n inputOptions.external = inputOptions.external.filter(id => !EDGE_INCOMPATIBLE_MODULES.includes(id as string));\n }\n }\n\n return inputOptions;\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot, enableEsmShim: this.target !== 'edge' },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n // Use Netlify Frameworks API config.json\n // https://docs.netlify.com/build/frameworks/frameworks-api/\n if (this.target === 'edge') {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n edge_functions: [\n {\n function: 'index',\n path: '/*',\n },\n ],\n });\n } else {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n functions: {\n directory: '.netlify/v1/functions',\n node_bundler: 'none', // Mastra pre-bundles, don't re-bundle\n included_files: ['.netlify/v1/functions/**'],\n },\n redirects: [\n {\n force: true,\n from: '/*',\n to: '/.netlify/functions/api/:splat',\n status: 200,\n },\n ],\n });\n }\n\n await move(join(outputDirectory, '.netlify', 'v1'), join(process.cwd(), '.netlify', 'v1'), {\n overwrite: true,\n });\n\n return result;\n }\n\n private getEntry(): string {\n return `\n import { handle } from 'hono/netlify'\n import { mastra } from '#mastra';\n import { createHonoServer, getToolExports } from '#server';\n import { tools } from '#tools';\n import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\n\n if (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n }\n\n const app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\n export default handle(app)\n`;\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n // LibSQL uses native Node.js bindings — incompatible with both serverless and edge environments\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger?.error(\n `Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.\n LibSQL with file URLs uses native Node.js bindings that cannot run in Netlify serverless or edge environments. Use other Mastra Storage options instead.`,\n );\n process.exit(1);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,WAAW,IAAI,IAAIA,SAAAA,eAAe,QAAO,MAAK,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC;;;;;AAMvE,SAAS,oBAAoB;CAC3B,OAAO;EACL,MAAM;EACN,UAAU,QAAgB;GACxB,MAAM,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;GAC/B,IAAI,SAAS,IAAI,IAAI,KAAK,CAAC,OAAO,WAAW,OAAO,GAClD,OAAO;IAAE,IAAI,QAAQ;IAAU,UAAU;GAAK;GAEhD,OAAO;EACT;CACF;AACF;;AAGA,MAAM,4BAA4B;CAAC;CAAc;CAAkB;AAAY;;;;;AAM/E,SAAS,8BAA8B;CACrC,MAAM,QAAQ,IAAI,IAAI,yBAAyB;CAC/C,MAAM,UAAU;CAChB,OAAO;EACL,MAAM;EACN,UAAU,QAAgB;GACxB,OAAO,MAAM,IAAI,MAAM,IAAI,UAAU;EACvC;EACA,KAAK,IAAY;GACf,IAAI,OAAO,SACT,OAAO;GAET,OAAO;EACT;CACF;AACF;AAcA,IAAa,kBAAb,cAAqCC,iBAAAA,SAAS;CAC5C;CAEA,YAAY,UAAkC,CAAC,GAAG;EAChD,MAAM,EAAE,MAAM,UAAU,CAAC;EAEzB,KAAK,SAAS,QAAQ,UAAU;EAEhC,KAAK,YACH,KAAK,WAAW,UAAA,GAAA,KAAA,KAAA,CAAc,YAAY,MAAM,gBAAgB,KAAA,G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K,SAAS,CACtC;EAIA,IAAI,KAAK,WAAW,QAClB,OAAA,GAAA,aAAA,UAAA,EAAA,GAAA,KAAA,KAAA,CAAqB,iBAAiB,YAAY,MAAM,aAAa,GAAG,EACtE,gBAAgB,CACd;GACE,UAAU;GACV,MAAM;EACR,CACF,EACF,CAAC;OAED,OAAA,GAAA,aAAA,UAAA,EAAA,GAAA,KAAA,KAAA,CAAqB,iBAAiB,YAAY,MAAM,aAAa,GAAG;GACtE,WAAW;IACT,WAAW;IACX,cAAc;IACd,gBAAgB,CAAC,0BAA0B;GAC7C;GACA,WAAW,CACT;IACE,OAAO;IACP,MAAM;IACN,IAAI;IACJ,QAAQ;GACV,CACF;EACF,CAAC;EAGH,OAAA,GAAA,aAAA,KAAA,EAAA,GAAA,KAAA,KAAA,CAAgB,iBAAiB,YAAY,IAAI,IAAA,GAAA,KAAA,KAAA,CAAQ,QAAA,QAAQ,IAAI,GAAG,YAAY,IAAI,GAAG,EACzF,WAAW,KACb,CAAC;EAED,OAAO;CACT;CAEA,WAA2B;EACzB,OAAO;;;;;;;;;;;;;;;CAeT;CAEA,MAAM,KAAK,WAAmB,iBAAyB,YAAkD;EACvG,MAAM,MAAM,KAAK,WAAW,iBAAiB,UAAU;EAKvD,IAFmB,MAAM,KAAK,KAAK,kBAAkB,CAAC,gBAAgB,CAAC,MAAO,MAE/D;GACb,KAAK,QAAQ,MACX;iKAEF;GACA,QAAA,QAAQ,KAAK,CAAC;EAChB;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["builtinModules","Deployer","DepsService"],"sources":["../src/index.ts"],"sourcesContent":["import { builtinModules } from 'node:module';\nimport { join } from 'node:path';\nimport process from 'node:process';\nimport { Deployer } from '@mastra/deployer';\nimport type { analyzeBundle } from '@mastra/deployer/analyze';\nimport type { BundlerOptions } from '@mastra/deployer/bundler';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\n/** Bare Node.js built-in module names (excludes internal `_`-prefixed ones). */\nconst builtins = new Set(builtinModules.filter(m => !m.startsWith('_')));\n\n/**\n * Rollup plugin that adds the `node:` prefix to bare Node.js built-in imports.\n * Deno requires `node:events` instead of `events`, `node:fs` instead of `fs`, etc.\n */\nfunction nodeBuiltinPrefix() {\n return {\n name: 'node-builtin-prefix',\n resolveId(source: string) {\n const base = source.split('/')[0]!;\n if (builtins.has(base) && !source.startsWith('node:')) {\n return { id: `node:${source}`, external: true };\n }\n return null;\n },\n };\n}\n\n/** Modules that Netlify's Edge bundler cannot resolve: native Node addons (`bufferutil`, `utf-8-validate`) and `typescript`. */\nconst EDGE_INCOMPATIBLE_MODULES = ['bufferutil', 'utf-8-validate', 'typescript'];\n\n/**\n * Rollup plugin that replaces edge-incompatible modules with an empty stub so\n * they do not appear as external imports in the bundle.\n */\nfunction stubEdgeIncompatibleModules() {\n const stubs = new Set(EDGE_INCOMPATIBLE_MODULES);\n const STUB_ID = '\\0mastra-netlify-edge-stub';\n return {\n name: 'stub-edge-incompatible-modules',\n resolveId(source: string) {\n return stubs.has(source) ? STUB_ID : null;\n },\n load(id: string) {\n if (id === STUB_ID) {\n return 'export default undefined;';\n }\n return null;\n },\n };\n}\n\nexport interface NetlifyDeployerOptions {\n /**\n * Deploy target for Netlify.\n *\n * - `'serverless'` — Standard Netlify Functions (Node.js runtime, 60s default timeout).\n * - `'edge'` — Netlify Edge Functions (Deno-based runtime, no hard timeout, runs at the edge).\n *\n * @default 'serverless'\n */\n target?: 'serverless' | 'edge';\n}\n\nexport class NetlifyDeployer extends Deployer {\n readonly target: 'serverless' | 'edge';\n\n constructor(options: NetlifyDeployerOptions = {}) {\n super({ name: 'NETLIFY' });\n\n this.target = options.target ?? 'serverless';\n\n this.outputDir =\n this.target === 'edge' ? join('.netlify', 'v1', 'edge-functions') : join('.netlify', 'v1', 'functions', 'api');\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n if (this.target === 'edge') {\n // Edge functions run on Deno — no platform-specific architecture constraints\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n } else {\n await deps.install({\n dir: join(outputDirectory, this.outputDir),\n architecture: {\n os: ['linux'],\n cpu: ['x64'],\n libc: ['gnu'],\n },\n });\n }\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Netlify failed. Please use the Netlify dashboard to deploy.');\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n bundlerOptions: BundlerOptions,\n additionalEntries: Record<string, string>,\n ) {\n const inputOptions = await super.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n {\n ...bundlerOptions,\n enableEsmShim: this.target !== 'edge',\n },\n additionalEntries,\n );\n\n if (this.target === 'edge' && Array.isArray(inputOptions.plugins)) {\n // Run before subpathExternalsResolver so the resolveId hooks win.\n inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());\n\n // Drop edge-incompatible modules from Rollup's external list so the stub plugin can redirect them.\n if (Array.isArray(inputOptions.external)) {\n inputOptions.external = inputOptions.external.filter(id => !EDGE_INCOMPATIBLE_MODULES.includes(id as string));\n }\n }\n\n return inputOptions;\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot, enableEsmShim: this.target !== 'edge' },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n // Use Netlify Frameworks API config.json\n // https://docs.netlify.com/build/frameworks/frameworks-api/\n if (this.target === 'edge') {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n edge_functions: [\n {\n function: 'index',\n path: '/*',\n },\n ],\n });\n } else {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n functions: {\n directory: '.netlify/v1/functions',\n node_bundler: 'none', // Mastra pre-bundles, don't re-bundle\n included_files: ['.netlify/v1/functions/**'],\n },\n redirects: [\n {\n force: true,\n from: '/*',\n to: '/.netlify/functions/api/:splat',\n status: 200,\n },\n ],\n });\n }\n\n await move(join(outputDirectory, '.netlify', 'v1'), join(process.cwd(), '.netlify', 'v1'), {\n overwrite: true,\n });\n\n return result;\n }\n\n private getEntry(): string {\n return `\n import { handle } from 'hono/netlify'\n import { mastra } from '#mastra';\n import { createHonoServer, getToolExports } from '#server';\n import { tools } from '#tools';\n import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\n\n if (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n }\n\n const app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\n export default handle(app)\n`;\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n // LibSQL uses native Node.js bindings — incompatible with both serverless and edge environments\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger?.error(\n `Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.\n LibSQL with file URLs uses native Node.js bindings that cannot run in Netlify serverless or edge environments. Use other Mastra Storage options instead.`,\n );\n process.exit(1);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,WAAW,IAAI,IAAIA,SAAAA,eAAe,QAAO,MAAK,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC;;;;;AAMvE,SAAS,oBAAoB;CAC3B,OAAO;EACL,MAAM;EACN,UAAU,QAAgB;GACxB,MAAM,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;GAC/B,IAAI,SAAS,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AAI,GAAG,EACzF,WAAW,KACb,CAAC;EAED,OAAO;CACT;CAEA,WAA2B;EACzB,OAAO;;;;;;;;;;;;;;;CAeT;CAEA,MAAM,KAAK,WAAmB,iBAAyB,YAAkD;EACvG,MAAM,MAAM,KAAK,WAAW,iBAAiB,UAAU;EAKvD,IAFmB,MAAM,KAAK,KAAK,kBAAkB,CAAC,gBAAgB,CAAC,MAAO,MAE/D;GACb,KAAK,QAAQ,MACX;iKAEF;GACA,QAAA,QAAQ,KAAK,CAAC;EAChB;CACF;AACF"}
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export declare class NetlifyDeployer extends Deployer {
18
18
  protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
19
19
  deploy(): Promise<void>;
20
20
  prepare(outputDirectory: string): Promise<void>;
21
- protected getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>, toolsPaths: (string | string[])[], bundlerOptions: BundlerOptions): Promise<import("./_types/rollup/dist/rollup.d.ts").InputOptions>;
21
+ protected getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>, toolsPaths: (string | string[])[], bundlerOptions: BundlerOptions, additionalEntries: Record<string, string>): Promise<import("./_types/rollup/dist/rollup.d.ts").InputOptions>;
22
22
  bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
23
23
  toolsPaths: (string | string[])[];
24
24
  projectRoot: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAgD/D,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,MAAM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sB;IACrC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;CAChC;AAED,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;gBAE3B,OAAO,GAAE,sBAA2B;cAShC,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,SAAgB;IAmB9E,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;cAIrC,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,EACvB,kBAAkB,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,EAC7D,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,EACjC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA2BrC,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IA6ChB,OAAO,CAAC,QAAQ;IAkBV,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAczG"}
package/dist/index.js CHANGED
@@ -74,11 +74,11 @@ var NetlifyDeployer = class extends Deployer {
74
74
  async prepare(outputDirectory) {
75
75
  await super.prepare(outputDirectory);
76
76
  }
77
- async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions) {
77
+ async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions, additionalEntries) {
78
78
  const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {
79
79
  ...bundlerOptions,
80
80
  enableEsmShim: this.target !== "edge"
81
- });
81
+ }, additionalEntries);
82
82
  if (this.target === "edge" && Array.isArray(inputOptions.plugins)) {
83
83
  inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());
84
84
  if (Array.isArray(inputOptions.external)) inputOptions.external = inputOptions.external.filter((id) => !EDGE_INCOMPATIBLE_MODULES.includes(id));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { builtinModules } from 'node:module';\nimport { join } from 'node:path';\nimport process from 'node:process';\nimport { Deployer } from '@mastra/deployer';\nimport type { analyzeBundle } from '@mastra/deployer/analyze';\nimport type { BundlerOptions } from '@mastra/deployer/bundler';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\n/** Bare Node.js built-in module names (excludes internal `_`-prefixed ones). */\nconst builtins = new Set(builtinModules.filter(m => !m.startsWith('_')));\n\n/**\n * Rollup plugin that adds the `node:` prefix to bare Node.js built-in imports.\n * Deno requires `node:events` instead of `events`, `node:fs` instead of `fs`, etc.\n */\nfunction nodeBuiltinPrefix() {\n return {\n name: 'node-builtin-prefix',\n resolveId(source: string) {\n const base = source.split('/')[0]!;\n if (builtins.has(base) && !source.startsWith('node:')) {\n return { id: `node:${source}`, external: true };\n }\n return null;\n },\n };\n}\n\n/** Modules that Netlify's Edge bundler cannot resolve: native Node addons (`bufferutil`, `utf-8-validate`) and `typescript`. */\nconst EDGE_INCOMPATIBLE_MODULES = ['bufferutil', 'utf-8-validate', 'typescript'];\n\n/**\n * Rollup plugin that replaces edge-incompatible modules with an empty stub so\n * they do not appear as external imports in the bundle.\n */\nfunction stubEdgeIncompatibleModules() {\n const stubs = new Set(EDGE_INCOMPATIBLE_MODULES);\n const STUB_ID = '\\0mastra-netlify-edge-stub';\n return {\n name: 'stub-edge-incompatible-modules',\n resolveId(source: string) {\n return stubs.has(source) ? STUB_ID : null;\n },\n load(id: string) {\n if (id === STUB_ID) {\n return 'export default undefined;';\n }\n return null;\n },\n };\n}\n\nexport interface NetlifyDeployerOptions {\n /**\n * Deploy target for Netlify.\n *\n * - `'serverless'` — Standard Netlify Functions (Node.js runtime, 60s default timeout).\n * - `'edge'` — Netlify Edge Functions (Deno-based runtime, no hard timeout, runs at the edge).\n *\n * @default 'serverless'\n */\n target?: 'serverless' | 'edge';\n}\n\nexport class NetlifyDeployer extends Deployer {\n readonly target: 'serverless' | 'edge';\n\n constructor(options: NetlifyDeployerOptions = {}) {\n super({ name: 'NETLIFY' });\n\n this.target = options.target ?? 'serverless';\n\n this.outputDir =\n this.target === 'edge' ? join('.netlify', 'v1', 'edge-functions') : join('.netlify', 'v1', 'functions', 'api');\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n if (this.target === 'edge') {\n // Edge functions run on Deno — no platform-specific architecture constraints\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n } else {\n await deps.install({\n dir: join(outputDirectory, this.outputDir),\n architecture: {\n os: ['linux'],\n cpu: ['x64'],\n libc: ['gnu'],\n },\n });\n }\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Netlify failed. Please use the Netlify dashboard to deploy.');\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n bundlerOptions: BundlerOptions,\n ) {\n const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {\n ...bundlerOptions,\n enableEsmShim: this.target !== 'edge',\n });\n\n if (this.target === 'edge' && Array.isArray(inputOptions.plugins)) {\n // Run before subpathExternalsResolver so the resolveId hooks win.\n inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());\n\n // Drop edge-incompatible modules from Rollup's external list so the stub plugin can redirect them.\n if (Array.isArray(inputOptions.external)) {\n inputOptions.external = inputOptions.external.filter(id => !EDGE_INCOMPATIBLE_MODULES.includes(id as string));\n }\n }\n\n return inputOptions;\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot, enableEsmShim: this.target !== 'edge' },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n // Use Netlify Frameworks API config.json\n // https://docs.netlify.com/build/frameworks/frameworks-api/\n if (this.target === 'edge') {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n edge_functions: [\n {\n function: 'index',\n path: '/*',\n },\n ],\n });\n } else {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n functions: {\n directory: '.netlify/v1/functions',\n node_bundler: 'none', // Mastra pre-bundles, don't re-bundle\n included_files: ['.netlify/v1/functions/**'],\n },\n redirects: [\n {\n force: true,\n from: '/*',\n to: '/.netlify/functions/api/:splat',\n status: 200,\n },\n ],\n });\n }\n\n await move(join(outputDirectory, '.netlify', 'v1'), join(process.cwd(), '.netlify', 'v1'), {\n overwrite: true,\n });\n\n return result;\n }\n\n private getEntry(): string {\n return `\n import { handle } from 'hono/netlify'\n import { mastra } from '#mastra';\n import { createHonoServer, getToolExports } from '#server';\n import { tools } from '#tools';\n import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\n\n if (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n }\n\n const app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\n export default handle(app)\n`;\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n // LibSQL uses native Node.js bindings — incompatible with both serverless and edge environments\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger?.error(\n `Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.\n LibSQL with file URLs uses native Node.js bindings that cannot run in Netlify serverless or edge environments. Use other Mastra Storage options instead.`,\n );\n process.exit(1);\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,WAAW,IAAI,IAAI,eAAe,QAAO,MAAK,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC;;;;;AAMvE,SAAS,oBAAoB;CAC3B,OAAO;EACL,MAAM;EACN,UAAU,QAAgB;GACxB,MAAM,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;GAC/B,IAAI,SAAS,IAAI,IAAI,KAAK,CAAC,OAAO,WAAW,OAAO,GAClD,OAAO;IAAE,IAAI,QAAQ;IAAU,UAAU;GAAK;GAEhD,OAAO;EACT;CACF;AACF;;AAGA,MAAM,4BAA4B;CAAC;CAAc;CAAkB;AAAY;;;;;AAM/E,SAAS,8BAA8B;CACrC,MAAM,QAAQ,IAAI,IAAI,yBAAyB;CAC/C,MAAM,UAAU;CAChB,OAAO;EACL,MAAM;EACN,UAAU,QAAgB;GACxB,OAAO,MAAM,IAAI,MAAM,IAAI,UAAU;EACvC;EACA,KAAK,IAAY;GACf,IAAI,OAAO,SACT,OAAO;GAET,OAAO;EACT;CACF;AACF;AAcA,IAAa,kBAAb,cAAqC,SAAS;CAC5C;CAEA,YAAY,UAAkC,CAAC,GAAG;EAChD,MAAM,EAAE,MAAM,UAAU,CAAC;EAEzB,KAAK,SAAS,QAAQ,UAAU;EAEhC,KAAK,YACH,KAA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AClB,MAAM,UAAU,KAAK,iBAAiB,YAAY,MAAM,aAAa,GAAG,EACtE,gBAAgB,CACd;GACE,UAAU;GACV,MAAM;EACR,CACF,EACF,CAAC;OAED,MAAM,UAAU,KAAK,iBAAiB,YAAY,MAAM,aAAa,GAAG;GACtE,WAAW;IACT,WAAW;IACX,cAAc;IACd,gBAAgB,CAAC,0BAA0B;GAC7C;GACA,WAAW,CACT;IACE,OAAO;IACP,MAAM;IACN,IAAI;IACJ,QAAQ;GACV,CACF;EACF,CAAC;EAGH,MAAM,KAAK,KAAK,iBAAiB,YAAY,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,IAAI,GAAG,EACzF,WAAW,KACb,CAAC;EAED,OAAO;CACT;CAEA,WAA2B;EACzB,OAAO;;;;;;;;;;;;;;;CAeT;CAEA,MAAM,KAAK,WAAmB,iBAAyB,YAAkD;EACvG,MAAM,MAAM,KAAK,WAAW,iBAAiB,UAAU;EAKvD,IAFmB,MAAM,KAAK,KAAK,kBAAkB,CAAC,gBAAgB,CAAC,MAAO,MAE/D;GACb,KAAK,QAAQ,MACX;iKAEF;GACA,QAAQ,KAAK,CAAC;EAChB;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { builtinModules } from 'node:module';\nimport { join } from 'node:path';\nimport process from 'node:process';\nimport { Deployer } from '@mastra/deployer';\nimport type { analyzeBundle } from '@mastra/deployer/analyze';\nimport type { BundlerOptions } from '@mastra/deployer/bundler';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\n/** Bare Node.js built-in module names (excludes internal `_`-prefixed ones). */\nconst builtins = new Set(builtinModules.filter(m => !m.startsWith('_')));\n\n/**\n * Rollup plugin that adds the `node:` prefix to bare Node.js built-in imports.\n * Deno requires `node:events` instead of `events`, `node:fs` instead of `fs`, etc.\n */\nfunction nodeBuiltinPrefix() {\n return {\n name: 'node-builtin-prefix',\n resolveId(source: string) {\n const base = source.split('/')[0]!;\n if (builtins.has(base) && !source.startsWith('node:')) {\n return { id: `node:${source}`, external: true };\n }\n return null;\n },\n };\n}\n\n/** Modules that Netlify's Edge bundler cannot resolve: native Node addons (`bufferutil`, `utf-8-validate`) and `typescript`. */\nconst EDGE_INCOMPATIBLE_MODULES = ['bufferutil', 'utf-8-validate', 'typescript'];\n\n/**\n * Rollup plugin that replaces edge-incompatible modules with an empty stub so\n * they do not appear as external imports in the bundle.\n */\nfunction stubEdgeIncompatibleModules() {\n const stubs = new Set(EDGE_INCOMPATIBLE_MODULES);\n const STUB_ID = '\\0mastra-netlify-edge-stub';\n return {\n name: 'stub-edge-incompatible-modules',\n resolveId(source: string) {\n return stubs.has(source) ? STUB_ID : null;\n },\n load(id: string) {\n if (id === STUB_ID) {\n return 'export default undefined;';\n }\n return null;\n },\n };\n}\n\nexport interface NetlifyDeployerOptions {\n /**\n * Deploy target for Netlify.\n *\n * - `'serverless'` — Standard Netlify Functions (Node.js runtime, 60s default timeout).\n * - `'edge'` — Netlify Edge Functions (Deno-based runtime, no hard timeout, runs at the edge).\n *\n * @default 'serverless'\n */\n target?: 'serverless' | 'edge';\n}\n\nexport class NetlifyDeployer extends Deployer {\n readonly target: 'serverless' | 'edge';\n\n constructor(options: NetlifyDeployerOptions = {}) {\n super({ name: 'NETLIFY' });\n\n this.target = options.target ?? 'serverless';\n\n this.outputDir =\n this.target === 'edge' ? join('.netlify', 'v1', 'edge-functions') : join('.netlify', 'v1', 'functions', 'api');\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n if (this.target === 'edge') {\n // Edge functions run on Deno — no platform-specific architecture constraints\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n } else {\n await deps.install({\n dir: join(outputDirectory, this.outputDir),\n architecture: {\n os: ['linux'],\n cpu: ['x64'],\n libc: ['gnu'],\n },\n });\n }\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Netlify failed. Please use the Netlify dashboard to deploy.');\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n bundlerOptions: BundlerOptions,\n additionalEntries: Record<string, string>,\n ) {\n const inputOptions = await super.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n {\n ...bundlerOptions,\n enableEsmShim: this.target !== 'edge',\n },\n additionalEntries,\n );\n\n if (this.target === 'edge' && Array.isArray(inputOptions.plugins)) {\n // Run before subpathExternalsResolver so the resolveId hooks win.\n inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());\n\n // Drop edge-incompatible modules from Rollup's external list so the stub plugin can redirect them.\n if (Array.isArray(inputOptions.external)) {\n inputOptions.external = inputOptions.external.filter(id => !EDGE_INCOMPATIBLE_MODULES.includes(id as string));\n }\n }\n\n return inputOptions;\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot, enableEsmShim: this.target !== 'edge' },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n // Use Netlify Frameworks API config.json\n // https://docs.netlify.com/build/frameworks/frameworks-api/\n if (this.target === 'edge') {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n edge_functions: [\n {\n function: 'index',\n path: '/*',\n },\n ],\n });\n } else {\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n functions: {\n directory: '.netlify/v1/functions',\n node_bundler: 'none', // Mastra pre-bundles, don't re-bundle\n included_files: ['.netlify/v1/functions/**'],\n },\n redirects: [\n {\n force: true,\n from: '/*',\n to: '/.netlify/functions/api/:splat',\n status: 200,\n },\n ],\n });\n }\n\n await move(join(outputDirectory, '.netlify', 'v1'), join(process.cwd(), '.netlify', 'v1'), {\n overwrite: true,\n });\n\n return result;\n }\n\n private getEntry(): string {\n return `\n import { handle } from 'hono/netlify'\n import { mastra } from '#mastra';\n import { createHonoServer, getToolExports } from '#server';\n import { tools } from '#tools';\n import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\n\n if (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n }\n\n const app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\n export default handle(app)\n`;\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n // LibSQL uses native Node.js bindings — incompatible with both serverless and edge environments\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger?.error(\n `Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.\n LibSQL with file URLs uses native Node.js bindings that cannot run in Netlify serverless or edge environments. Use other Mastra Storage options instead.`,\n );\n process.exit(1);\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,WAAW,IAAI,IAAI,eAAe,QAAO,MAAK,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC;;;;;AAMvE,SAAS,oBAAoB;CAC3B,OAAO;EACL,MAAM;EACN,UAAU,QAAgB;GACxB,MAAM,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;GAC/B,IAAI,SAAS,IAAI,IAAI,KAAK,CAAC,OAAO,WAAW,OAAO,GAClD,OAAO;IAAE,IAAI,QAAQ;IAAU,UAAU;GAAK;GAEhD,OAAO;EACT;CACF;AACF;;AAGA,MAAM,4BAA4B;CAAC;CAAc;CAAkB;AAAY;;;;;AAM/E,SAAS,8BAA8B;CACrC,MAAM,QAAQ,IAAI,IAAI,yBAAyB;CAC/C,MA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AAQ,aAAa,QAAQ,GACrC,aAAa,WAAW,aAAa,SAAS,QAAO,OAAM,CAAC,0BAA0B,SAAS,EAAY,CAAC;EAEhH;EAEA,OAAO;CACT;CAEA,MAAM,OACJ,WACA,iBACA,EAAE,YAAY,eACC;EACf,MAAM,SAAS,MAAM,KAAK,QACxB,KAAK,SAAS,GACd,WACA;GAAE;GAAiB;GAAa,eAAe,KAAK,WAAW;EAAO,GACtE,YACA,KAAK,iBAAiB,KAAK,SAAS,CACtC;EAIA,IAAI,KAAK,WAAW,QAClB,MAAM,UAAU,KAAK,iBAAiB,YAAY,MAAM,aAAa,GAAG,EACtE,gBAAgB,CACd;GACE,UAAU;GACV,MAAM;EACR,CACF,EACF,CAAC;OAED,MAAM,UAAU,KAAK,iBAAiB,YAAY,MAAM,aAAa,GAAG;GACtE,WAAW;IACT,WAAW;IACX,cAAc;IACd,gBAAgB,CAAC,0BAA0B;GAC7C;GACA,WAAW,CACT;IACE,OAAO;IACP,MAAM;IACN,IAAI;IACJ,QAAQ;GACV,CACF;EACF,CAAC;EAGH,MAAM,KAAK,KAAK,iBAAiB,YAAY,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,IAAI,GAAG,EACzF,WAAW,KACb,CAAC;EAED,OAAO;CACT;CAEA,WAA2B;EACzB,OAAO;;;;;;;;;;;;;;;CAeT;CAEA,MAAM,KAAK,WAAmB,iBAAyB,YAAkD;EACvG,MAAM,MAAM,KAAK,WAAW,iBAAiB,UAAU;EAKvD,IAFmB,MAAM,KAAK,KAAK,kBAAkB,CAAC,gBAAgB,CAAC,MAAO,MAE/D;GACb,KAAK,QAAQ,MACX;iKAEF;GACA,QAAQ,KAAK,CAAC;EAChB;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "1.2.20-alpha.0",
3
+ "version": "1.2.20",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "fs-extra": "^11.3.5",
30
30
  "rollup": "^4.61.1",
31
- "@mastra/deployer": "^1.63.0-alpha.0"
31
+ "@mastra/deployer": "^1.63.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/fs-extra": "^11.0.4",
@@ -39,9 +39,9 @@
39
39
  "tsdown": "0.22.9",
40
40
  "typescript": "^6.0.3",
41
41
  "vitest": "4.1.10",
42
- "@internal/types-builder": "0.0.101",
43
- "@mastra/core": "1.63.0-alpha.0",
44
- "@internal/lint": "0.0.126"
42
+ "@internal/types-builder": "0.0.102",
43
+ "@internal/lint": "0.0.127",
44
+ "@mastra/core": "1.63.0"
45
45
  },
46
46
  "homepage": "https://mastra.ai",
47
47
  "repository": {