Demonstrates a Firebase Functions for Dart project that depends on a package
with a native build hook — sqlite3, which compiles a C library as part of
the build.
Deploying a Dart functions project normally cross-compiles it with
dart compile exe, which refuses to run build hooks:
'dart compile' does not support build hooks, use 'dart build' instead.
Packages with build hooks: sqlite3.
This happens even if the package is only a transitive dependency and your own code never imports it.
Declaring an SDK constraint of ^3.13.0 opts the project into dart build cli,
which runs build hooks while cross-compiling for Cloud Run:
environment:
sdk: ^3.13.0Dart 3.13 is the release where dart build cli gained --target-os and
--target-arch. Projects below that constraint keep using dart compile exe.
Any project declaring ^3.13.0 takes the bundle path, whether or not it has
native dependencies, and needs firebase-tools 15.28.1 or later to deploy.
See Native Dependencies for the full explanation.
sqliteDemo opens an in-memory database, writes a few rows, and returns the
row count alongside the linked SQLite version — proving the native library was
built and loaded successfully at runtime:
sqlite3 3.53.4, items: 3
FIREBASE_PROJECT=demo-test PORT=8080 dart run bin/server.dartThen, in another terminal:
curl http://localhost:8080/sqlitedemoNote the lowercase path: function names are lowercased to form valid Cloud Run
service IDs, so sqliteDemo is served at /sqlitedemo.
firebase deploy --only functions --project YOUR_PROJECTDeploying requires Dart 3.13.0 or later installed locally, since that is the
first release in which dart build cli can cross-compile.