Building
dart run spring_boot_starter_edge:build compiles the application (dart compile js -O2 -DSPRING_ALL_PLATFORMS=true) and writes the entry file of the platform next to it. Nothing of it is written by hand, and nothing of it is committed.
dart run build_runner build
dart run spring_boot_starter_edge:build --platform supabase --name api
What is written
--platform |
Written to | Files | Deploy |
|---|---|---|---|
supabase |
supabase/functions/<name>/ |
index.ts, main.js, prelude.js |
supabase functions deploy <name> |
cloudflare |
build/cloudflare/ |
worker.mjs, main.js, prelude.js; wrangler.toml in the application's directory (once) |
npx wrangler deploy |
aws |
build/aws/ |
index.mjs, main.cjs, prelude.js |
zip the directory; runtime Node.js 22, handler index.handler |
deno |
build/deno/ |
main.ts, main.js, prelude.js |
Deno Deploy with main.ts as the entry point; anywhere else deno run -A main.ts (PORT) |
netlify |
netlify/edge-functions/<name>/ |
index.js, main.js, prelude.js |
Netlify's build runs the command |
vercel |
build/vercel/ |
index.mjs, main.cjs, prelude.js |
the function of a Vercel project (its fetch export) |
Options
| Option | |
|---|---|
--name, -n |
The function's name, api by default. On Supabase and Netlify its directory, on Supabase also the first segment of its paths; the Worker's name in a new wrangler.toml |
--target, -t |
js (the default) or wasm |
--entry |
The Dart file with main, bin/main.dart by default |
--output, -o |
The function's directory |
--optimization |
The -O level of the compiler, 0 to 4, 2 by default |
--dart |
The dart that compiles; dart on the PATH by default. WebAssembly for Supabase needs that of Dart 3.13 |
--streaming |
AWS: a response-streaming handler (see AWS Lambda) |
--path |
Netlify: the paths the function answers, /* by default |
-D<name>=<value> |
A definition for the compiler |
Size
A function with the web and security starters is about 1.8 MB of JavaScript (0.6 MB gzipped); its context starts in 50 to 250 ms, depending on the platform.
WebAssembly
--target wasm compiles with dart compile wasm (WasmGC): app.wasm (about 1.7 MB) with its app.mjs, and a small loader in place of the script; the entry file is the same. The code of the application does not change.
Warning
WebAssembly on Supabase: compiled by Dart 3.13 only, for now. Supabase's Edge Runtime is Deno 2.1, whose V8 (13.0) lacks the WebAssembly exception handling (exnref) that dart compile wasm uses from Dart 3.14 on (Flutter 3.50). Until Supabase updates it, compile the function with Dart 3.13: --dart <the dart of a Dart 3.13 SDK>. A build by a later Dart is refused and says so. JavaScript works with every Dart, and WebAssembly on every other platform.
| Platform | WebAssembly |
|---|---|
| Supabase | compiled by Dart 3.13 only, until Supabase updates its Edge Runtime: it is Deno 2.1, whose V8 (13.0) lacks the WebAssembly exception handling (exnref) that dart compile wasm uses from Dart 3.14 on. Build with --dart <the dart of a Dart 3.13 SDK> (the build itself runs on any Dart; a later Dart is refused, saying so), and list the module in config.toml: [functions.<name>] static_files = ["./functions/<name>/*.wasm"] |
| Cloudflare | yes: wrangler compiles the module at deploy (a Worker may not at run time) |
| AWS Lambda (Node.js 22) | yes |
| Deno Deploy | yes |
| Netlify, Vercel | not checked |
A deploy workflow
dart run spring_boot_starter_edge:workflow --platform supabase --name api
writes .github/workflows/deploy-<name>.yml into the repository of the application: on every push to main (--branch) it runs the generator, builds the function (--target) and deploys it. For supabase (supabase functions deploy), cloudflare (wrangler deploy) and aws (aws lambda update-function-code, with GitHub's OIDC).
What it needs is named in its first lines and comes from the repository's secrets and variables; nothing secret is written:
| Platform | Needs |
|---|---|
supabase |
secrets SUPABASE_ACCESS_TOKEN, SUPABASE_PROJECT_REF |
cloudflare |
secrets CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID |
aws |
secret AWS_ROLE_ARN; variables AWS_REGION, AWS_LAMBDA_FUNCTION |
The file is yours afterwards (--force replaces it). The steps by hand, the secrets of each platform and checking a deployed function are in Deploying a function. Deno Deploy, Netlify and Vercel deploy from the repository themselves: give them the build command.
As code
package:spring_boot_starter_edge/build.dart has the same build as code (EdgeBuild), for build scripts and tests.