@mastra/deployer-netlify 1.0.28-alpha.0 → 1.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/index.cjs +89 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -28
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @mastra/deployer-netlify
|
|
2
2
|
|
|
3
|
+
## 1.1.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `target` option to `NetlifyDeployer` for deploying as Netlify Edge Functions. ([#13103](https://github.com/mastra-ai/mastra/pull/13103))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
export const mastra = new Mastra({
|
|
11
|
+
deployer: new NetlifyDeployer({
|
|
12
|
+
target: 'edge',
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Edge functions run on Deno at the network edge, closer to users, with no hard execution timeout (only a CPU time limit). This makes them a better fit for longer-running AI workflows that may exceed the 60s serverless function timeout.
|
|
18
|
+
|
|
19
|
+
The default target remains `'serverless'`, so existing usage is unaffected.
|
|
20
|
+
|
|
21
|
+
## 1.0.28-alpha.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`3d83d06`](https://github.com/mastra-ai/mastra/commit/3d83d06f776f00fb5f4163dddd32a030c5c20844), [`7e0e63e`](https://github.com/mastra-ai/mastra/commit/7e0e63e2e485e84442351f4c7a79a424c83539dc), [`9467ea8`](https://github.com/mastra-ai/mastra/commit/9467ea87695749a53dfc041576410ebf9ee7bb67), [`7338d94`](https://github.com/mastra-ai/mastra/commit/7338d949380cf68b095342e8e42610dc51d557c1)]:
|
|
26
|
+
- @mastra/core@1.26.0-alpha.2
|
|
27
|
+
- @mastra/deployer@1.26.0-alpha.2
|
|
28
|
+
|
|
3
29
|
## 1.0.28-alpha.0
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var module$1 = require('module');
|
|
3
4
|
var path = require('path');
|
|
4
5
|
var process = require('process');
|
|
5
6
|
var deployer = require('@mastra/deployer');
|
|
@@ -11,22 +12,58 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
11
12
|
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
12
13
|
|
|
13
14
|
// src/index.ts
|
|
15
|
+
var builtins = new Set(module$1.builtinModules.filter((m) => !m.startsWith("_")));
|
|
16
|
+
function nodeBuiltinPrefix() {
|
|
17
|
+
return {
|
|
18
|
+
name: "node-builtin-prefix",
|
|
19
|
+
resolveId(source) {
|
|
20
|
+
const base = source.split("/")[0];
|
|
21
|
+
if (builtins.has(base) && !source.startsWith("node:")) {
|
|
22
|
+
return { id: `node:${source}`, external: true };
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var EDGE_INCOMPATIBLE_MODULES = ["bufferutil", "utf-8-validate", "typescript"];
|
|
29
|
+
function stubEdgeIncompatibleModules() {
|
|
30
|
+
const stubs = new Set(EDGE_INCOMPATIBLE_MODULES);
|
|
31
|
+
const STUB_ID = "\0mastra-netlify-edge-stub";
|
|
32
|
+
return {
|
|
33
|
+
name: "stub-edge-incompatible-modules",
|
|
34
|
+
resolveId(source) {
|
|
35
|
+
return stubs.has(source) ? STUB_ID : null;
|
|
36
|
+
},
|
|
37
|
+
load(id) {
|
|
38
|
+
if (id === STUB_ID) {
|
|
39
|
+
return "export default undefined;";
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
14
45
|
var NetlifyDeployer = class extends deployer.Deployer {
|
|
15
|
-
|
|
46
|
+
target;
|
|
47
|
+
constructor(options = {}) {
|
|
16
48
|
super({ name: "NETLIFY" });
|
|
17
|
-
this.
|
|
49
|
+
this.target = options.target ?? "serverless";
|
|
50
|
+
this.outputDir = this.target === "edge" ? path.join(".netlify", "v1", "edge-functions") : path.join(".netlify", "v1", "functions", "api");
|
|
18
51
|
}
|
|
19
52
|
async installDependencies(outputDirectory, rootDir = process__default.default.cwd()) {
|
|
20
53
|
const deps = new services.DepsService(rootDir);
|
|
21
54
|
deps.__setLogger(this.logger);
|
|
22
|
-
|
|
23
|
-
dir: path.join(outputDirectory, this.outputDir)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
55
|
+
if (this.target === "edge") {
|
|
56
|
+
await deps.install({ dir: path.join(outputDirectory, this.outputDir) });
|
|
57
|
+
} else {
|
|
58
|
+
await deps.install({
|
|
59
|
+
dir: path.join(outputDirectory, this.outputDir),
|
|
60
|
+
architecture: {
|
|
61
|
+
os: ["linux"],
|
|
62
|
+
cpu: ["x64"],
|
|
63
|
+
libc: ["gnu"]
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
30
67
|
}
|
|
31
68
|
async deploy() {
|
|
32
69
|
this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
|
|
@@ -34,30 +71,54 @@ var NetlifyDeployer = class extends deployer.Deployer {
|
|
|
34
71
|
async prepare(outputDirectory) {
|
|
35
72
|
await super.prepare(outputDirectory);
|
|
36
73
|
}
|
|
74
|
+
async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions) {
|
|
75
|
+
const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {
|
|
76
|
+
...bundlerOptions,
|
|
77
|
+
enableEsmShim: this.target !== "edge"
|
|
78
|
+
});
|
|
79
|
+
if (this.target === "edge" && Array.isArray(inputOptions.plugins)) {
|
|
80
|
+
inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());
|
|
81
|
+
if (Array.isArray(inputOptions.external)) {
|
|
82
|
+
inputOptions.external = inputOptions.external.filter((id) => !EDGE_INCOMPATIBLE_MODULES.includes(id));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return inputOptions;
|
|
86
|
+
}
|
|
37
87
|
async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
|
|
38
88
|
const result = await this._bundle(
|
|
39
89
|
this.getEntry(),
|
|
40
90
|
entryFile,
|
|
41
|
-
{ outputDirectory, projectRoot, enableEsmShim:
|
|
91
|
+
{ outputDirectory, projectRoot, enableEsmShim: this.target !== "edge" },
|
|
42
92
|
toolsPaths,
|
|
43
93
|
path.join(outputDirectory, this.outputDir)
|
|
44
94
|
);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
if (this.target === "edge") {
|
|
96
|
+
await esm.writeJson(path.join(outputDirectory, ".netlify", "v1", "config.json"), {
|
|
97
|
+
edge_functions: [
|
|
98
|
+
{
|
|
99
|
+
function: "index",
|
|
100
|
+
path: "/*"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
await esm.writeJson(path.join(outputDirectory, ".netlify", "v1", "config.json"), {
|
|
106
|
+
functions: {
|
|
107
|
+
directory: ".netlify/v1/functions",
|
|
108
|
+
node_bundler: "none",
|
|
109
|
+
// Mastra pre-bundles, don't re-bundle
|
|
110
|
+
included_files: [".netlify/v1/functions/**"]
|
|
111
|
+
},
|
|
112
|
+
redirects: [
|
|
113
|
+
{
|
|
114
|
+
force: true,
|
|
115
|
+
from: "/*",
|
|
116
|
+
to: "/.netlify/functions/api/:splat",
|
|
117
|
+
status: 200
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
61
122
|
await esm.move(path.join(outputDirectory, ".netlify", "v1"), path.join(process__default.default.cwd(), ".netlify", "v1"), {
|
|
62
123
|
overwrite: true
|
|
63
124
|
});
|
|
@@ -86,7 +147,7 @@ var NetlifyDeployer = class extends deployer.Deployer {
|
|
|
86
147
|
if (hasLibsql) {
|
|
87
148
|
this.logger?.error(
|
|
88
149
|
`Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.
|
|
89
|
-
LibSQL with file URLs uses native Node.js bindings that cannot run in serverless environments. Use other Mastra Storage options instead.`
|
|
150
|
+
LibSQL with file URLs uses native Node.js bindings that cannot run in Netlify serverless or edge environments. Use other Mastra Storage options instead.`
|
|
90
151
|
);
|
|
91
152
|
process__default.default.exit(1);
|
|
92
153
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["Deployer","join","process","DepsService","writeJson","move"],"mappings":";;;;;;;;;;;;;AAMO,IAAM,eAAA,GAAN,cAA8BA,iBAAA,CAAS;AAAA,EAC5C,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,SAAA,EAAW,CAAA;AACzB,IAAA,IAAA,CAAK,SAAA,GAAYC,SAAA,CAAK,UAAA,EAAY,IAAA,EAAM,aAAa,KAAK,CAAA;AAAA,EAC5D;AAAA,EAEA,MAAgB,mBAAA,CAAoB,eAAA,EAAyB,OAAA,GAAUC,wBAAA,CAAQ,KAAI,EAAG;AACpF,IAAA,MAAM,IAAA,GAAO,IAAIC,oBAAA,CAAY,OAAO,CAAA;AACpC,IAAA,IAAA,CAAK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AAAA;AACV;AACF,KACD,CAAA;AAED,IAAA,MAAMI,QAAA,CAAKJ,SAAA,CAAK,eAAA,EAAiB,UAAA,EAAY,IAAI,CAAA,EAAGA,SAAA,CAAKC,wBAAA,CAAQ,GAAA,EAAI,EAAG,UAAA,EAAY,IAAI,CAAA,EAAG;AAAA,MACzF,SAAA,EAAW;AAAA,KACZ,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEQ,QAAA,GAAmB;AACzB,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA,CAAA;AAAA,EAeT;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAGvD,IAAA,MAAM,SAAA,GAAa,MAAM,IAAA,CAAK,IAAA,CAAK,kBAAkB,CAAC,gBAAgB,CAAC,CAAA,KAAO,CAAA,EAAA,CAAA;AAE9E,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,IAAA,CAAK,MAAA,EAAQ,KAAA;AAAA,QACX,CAAA;AAAA,gJAAA;AAAA,OAEF;AACA,MAAAA,wBAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["import { join } from 'node:path';\nimport process from 'node:process';\nimport { Deployer } from '@mastra/deployer';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\nexport class NetlifyDeployer extends Deployer {\n constructor() {\n super({ name: 'NETLIFY' });\n this.outputDir = 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 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 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 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: true },\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 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 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 // Check for LibSQL dependency which is not supported in Netlify Functions\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 serverless environments. Use other Mastra Storage options instead.`,\n );\n process.exit(1);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["builtinModules","Deployer","join","process","DepsService","writeJson","move"],"mappings":";;;;;;;;;;;;;;AAUA,IAAM,QAAA,GAAW,IAAI,GAAA,CAAIA,uBAAA,CAAe,MAAA,CAAO,CAAA,CAAA,KAAK,CAAC,CAAA,CAAE,UAAA,CAAW,GAAG,CAAC,CAAC,CAAA;AAMvE,SAAS,iBAAA,GAAoB;AAC3B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,qBAAA;AAAA,IACN,UAAU,MAAA,EAAgB;AACxB,MAAA,MAAM,IAAA,GAAO,MAAA,CAAO,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAChC,MAAA,IAAI,QAAA,CAAS,IAAI,IAAI,CAAA,IAAK,CAAC,MAAA,CAAO,UAAA,CAAW,OAAO,CAAA,EAAG;AACrD,QAAA,OAAO,EAAE,EAAA,EAAI,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAA,EAAI,UAAU,IAAA,EAAK;AAAA,MAChD;AACA,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF;AAGA,IAAM,yBAAA,GAA4B,CAAC,YAAA,EAAc,gBAAA,EAAkB,YAAY,CAAA;AAM/E,SAAS,2BAAA,GAA8B;AACrC,EAAA,MAAM,KAAA,GAAQ,IAAI,GAAA,CAAI,yBAAyB,CAAA;AAC/C,EAAA,MAAM,OAAA,GAAU,4BAAA;AAChB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gCAAA;AAAA,IACN,UAAU,MAAA,EAAgB;AACxB,MAAA,OAAO,KAAA,CAAM,GAAA,CAAI,MAAM,CAAA,GAAI,OAAA,GAAU,IAAA;AAAA,IACvC,CAAA;AAAA,IACA,KAAK,EAAA,EAAY;AACf,MAAA,IAAI,OAAO,OAAA,EAAS;AAClB,QAAA,OAA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,IAAA,CAAK,IAAA,CAAK,kBAAkB,CAAC,gBAAgB,CAAC,CAAA,KAAO,CAAA,EAAA,CAAA;AAE9E,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,IAAA,CAAK,MAAA,EAAQ,KAAA;AAAA,QACX,CAAA;AAAA,gKAAA;AAAA,OAEF;AACA,MAAAA,wBAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.cjs","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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { Deployer } from '@mastra/deployer';
|
|
2
|
+
import type { analyzeBundle } from '@mastra/deployer/analyze';
|
|
3
|
+
import type { BundlerOptions } from '@mastra/deployer/bundler';
|
|
4
|
+
export interface NetlifyDeployerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Deploy target for Netlify.
|
|
7
|
+
*
|
|
8
|
+
* - `'serverless'` — Standard Netlify Functions (Node.js runtime, 60s default timeout).
|
|
9
|
+
* - `'edge'` — Netlify Edge Functions (Deno-based runtime, no hard timeout, runs at the edge).
|
|
10
|
+
*
|
|
11
|
+
* @default 'serverless'
|
|
12
|
+
*/
|
|
13
|
+
target?: 'serverless' | 'edge';
|
|
14
|
+
}
|
|
2
15
|
export declare class NetlifyDeployer extends Deployer {
|
|
3
|
-
|
|
16
|
+
readonly target: 'serverless' | 'edge';
|
|
17
|
+
constructor(options?: NetlifyDeployerOptions);
|
|
4
18
|
protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
|
|
5
19
|
deploy(): Promise<void>;
|
|
6
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("rollup").InputOptions>;
|
|
7
22
|
bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
|
|
8
23
|
toolsPaths: (string | string[])[];
|
|
9
24
|
projectRoot: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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,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;IAoB1B,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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { builtinModules } from 'module';
|
|
1
2
|
import { join } from 'path';
|
|
2
3
|
import process from 'process';
|
|
3
4
|
import { Deployer } from '@mastra/deployer';
|
|
@@ -5,22 +6,58 @@ import { DepsService } from '@mastra/deployer/services';
|
|
|
5
6
|
import { writeJson, move } from 'fs-extra/esm';
|
|
6
7
|
|
|
7
8
|
// src/index.ts
|
|
9
|
+
var builtins = new Set(builtinModules.filter((m) => !m.startsWith("_")));
|
|
10
|
+
function nodeBuiltinPrefix() {
|
|
11
|
+
return {
|
|
12
|
+
name: "node-builtin-prefix",
|
|
13
|
+
resolveId(source) {
|
|
14
|
+
const base = source.split("/")[0];
|
|
15
|
+
if (builtins.has(base) && !source.startsWith("node:")) {
|
|
16
|
+
return { id: `node:${source}`, external: true };
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var EDGE_INCOMPATIBLE_MODULES = ["bufferutil", "utf-8-validate", "typescript"];
|
|
23
|
+
function stubEdgeIncompatibleModules() {
|
|
24
|
+
const stubs = new Set(EDGE_INCOMPATIBLE_MODULES);
|
|
25
|
+
const STUB_ID = "\0mastra-netlify-edge-stub";
|
|
26
|
+
return {
|
|
27
|
+
name: "stub-edge-incompatible-modules",
|
|
28
|
+
resolveId(source) {
|
|
29
|
+
return stubs.has(source) ? STUB_ID : null;
|
|
30
|
+
},
|
|
31
|
+
load(id) {
|
|
32
|
+
if (id === STUB_ID) {
|
|
33
|
+
return "export default undefined;";
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
8
39
|
var NetlifyDeployer = class extends Deployer {
|
|
9
|
-
|
|
40
|
+
target;
|
|
41
|
+
constructor(options = {}) {
|
|
10
42
|
super({ name: "NETLIFY" });
|
|
11
|
-
this.
|
|
43
|
+
this.target = options.target ?? "serverless";
|
|
44
|
+
this.outputDir = this.target === "edge" ? join(".netlify", "v1", "edge-functions") : join(".netlify", "v1", "functions", "api");
|
|
12
45
|
}
|
|
13
46
|
async installDependencies(outputDirectory, rootDir = process.cwd()) {
|
|
14
47
|
const deps = new DepsService(rootDir);
|
|
15
48
|
deps.__setLogger(this.logger);
|
|
16
|
-
|
|
17
|
-
dir: join(outputDirectory, this.outputDir)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
49
|
+
if (this.target === "edge") {
|
|
50
|
+
await deps.install({ dir: join(outputDirectory, this.outputDir) });
|
|
51
|
+
} else {
|
|
52
|
+
await deps.install({
|
|
53
|
+
dir: join(outputDirectory, this.outputDir),
|
|
54
|
+
architecture: {
|
|
55
|
+
os: ["linux"],
|
|
56
|
+
cpu: ["x64"],
|
|
57
|
+
libc: ["gnu"]
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
24
61
|
}
|
|
25
62
|
async deploy() {
|
|
26
63
|
this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
|
|
@@ -28,30 +65,54 @@ var NetlifyDeployer = class extends Deployer {
|
|
|
28
65
|
async prepare(outputDirectory) {
|
|
29
66
|
await super.prepare(outputDirectory);
|
|
30
67
|
}
|
|
68
|
+
async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, bundlerOptions) {
|
|
69
|
+
const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, {
|
|
70
|
+
...bundlerOptions,
|
|
71
|
+
enableEsmShim: this.target !== "edge"
|
|
72
|
+
});
|
|
73
|
+
if (this.target === "edge" && Array.isArray(inputOptions.plugins)) {
|
|
74
|
+
inputOptions.plugins.unshift(nodeBuiltinPrefix(), stubEdgeIncompatibleModules());
|
|
75
|
+
if (Array.isArray(inputOptions.external)) {
|
|
76
|
+
inputOptions.external = inputOptions.external.filter((id) => !EDGE_INCOMPATIBLE_MODULES.includes(id));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return inputOptions;
|
|
80
|
+
}
|
|
31
81
|
async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
|
|
32
82
|
const result = await this._bundle(
|
|
33
83
|
this.getEntry(),
|
|
34
84
|
entryFile,
|
|
35
|
-
{ outputDirectory, projectRoot, enableEsmShim:
|
|
85
|
+
{ outputDirectory, projectRoot, enableEsmShim: this.target !== "edge" },
|
|
36
86
|
toolsPaths,
|
|
37
87
|
join(outputDirectory, this.outputDir)
|
|
38
88
|
);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
89
|
+
if (this.target === "edge") {
|
|
90
|
+
await writeJson(join(outputDirectory, ".netlify", "v1", "config.json"), {
|
|
91
|
+
edge_functions: [
|
|
92
|
+
{
|
|
93
|
+
function: "index",
|
|
94
|
+
path: "/*"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
await writeJson(join(outputDirectory, ".netlify", "v1", "config.json"), {
|
|
100
|
+
functions: {
|
|
101
|
+
directory: ".netlify/v1/functions",
|
|
102
|
+
node_bundler: "none",
|
|
103
|
+
// Mastra pre-bundles, don't re-bundle
|
|
104
|
+
included_files: [".netlify/v1/functions/**"]
|
|
105
|
+
},
|
|
106
|
+
redirects: [
|
|
107
|
+
{
|
|
108
|
+
force: true,
|
|
109
|
+
from: "/*",
|
|
110
|
+
to: "/.netlify/functions/api/:splat",
|
|
111
|
+
status: 200
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
55
116
|
await move(join(outputDirectory, ".netlify", "v1"), join(process.cwd(), ".netlify", "v1"), {
|
|
56
117
|
overwrite: true
|
|
57
118
|
});
|
|
@@ -80,7 +141,7 @@ var NetlifyDeployer = class extends Deployer {
|
|
|
80
141
|
if (hasLibsql) {
|
|
81
142
|
this.logger?.error(
|
|
82
143
|
`Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.
|
|
83
|
-
LibSQL with file URLs uses native Node.js bindings that cannot run in serverless environments. Use other Mastra Storage options instead.`
|
|
144
|
+
LibSQL with file URLs uses native Node.js bindings that cannot run in Netlify serverless or edge environments. Use other Mastra Storage options instead.`
|
|
84
145
|
);
|
|
85
146
|
process.exit(1);
|
|
86
147
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAMO,IAAM,eAAA,GAAN,cAA8B,QAAA,CAAS;AAAA,EAC5C,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,SAAA,EAAW,CAAA;AACzB,IAAA,IAAA,CAAK,SAAA,GAAY,IAAA,CAAK,UAAA,EAAY,IAAA,EAAM,aAAa,KAAK,CAAA;AAAA,EAC5D;AAAA,EAEA,MAAgB,mBAAA,CAAoB,eAAA,EAAyB,OAAA,GAAU,OAAA,CAAQ,KAAI,EAAG;AACpF,IAAA,MAAM,IAAA,GAAO,IAAI,WAAA,CAAY,OAAO,CAAA;AACpC,IAAA,IAAA,CAAK,WAAA,CAAY,KAAK,MAAM,CAAA;AAE5B,IAAA,MAAM,KAAK,OAAA,CAAQ;AAAA,MACjB,GAAA,EAAK,IAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,SAAS,CAAA;AAAA,MACzC,YAAA,EAAc;AAAA,QACZ,EAAA,EAAI,CAAC,OAA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W;AAAA,KACZ,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEQ,QAAA,GAAmB;AACzB,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA,CAAA;AAAA,EAeT;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAGvD,IAAA,MAAM,SAAA,GAAa,MAAM,IAAA,CAAK,IAAA,CAAK,kBAAkB,CAAC,gBAAgB,CAAC,CAAA,KAAO,CAAA,EAAA,CAAA;AAE9E,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,IAAA,CAAK,MAAA,EAAQ,KAAA;AAAA,QACX,CAAA;AAAA,gJAAA;AAAA,OAEF;AACA,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import { join } from 'node:path';\nimport process from 'node:process';\nimport { Deployer } from '@mastra/deployer';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\nexport class NetlifyDeployer extends Deployer {\n constructor() {\n super({ name: 'NETLIFY' });\n this.outputDir = 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 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 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 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: true },\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 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 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 // Check for LibSQL dependency which is not supported in Netlify Functions\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 serverless environments. Use other Mastra Storage options instead.`,\n );\n process.exit(1);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;AAUA,IAAM,QAAA,GAAW,IAAI,GAAA,CAAI,cAAA,CAAe,MAAA,CAAO,C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ent":["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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-netlify",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"fs-extra": "^11.3.4",
|
|
30
|
-
"@mastra/deployer": "^1.
|
|
30
|
+
"@mastra/deployer": "^1.26.0-alpha.8"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
40
|
"vitest": "4.0.18",
|
|
41
41
|
"@internal/lint": "0.0.83",
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
42
|
+
"@mastra/core": "1.26.0-alpha.8",
|
|
43
|
+
"@internal/types-builder": "0.0.58"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://mastra.ai",
|
|
46
46
|
"repository": {
|