Skip to content

Commit 7e199d4

Browse files
committed
fix(og): include @takumi-rs/core-linux-x64-gnu binary in function bundle
`external_node_modules = ["@takumi-rs/core"]` alone wasn't enough — Netlify's bundler ships the package and its declared deps but doesn't trace optional platform-specific deps loaded via napi-rs's runtime require dispatcher. Confirmed via diagnostic 500 body on the deploy preview: "Cannot find native binding. npm has a bug related to optional dependencies". List the Linux x64 binary package explicitly so the .node file is included alongside the loader.
1 parent 13330a7 commit 7e199d4

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

netlify.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ included_files = [
1313
"public/images/logos/splash-dark.png",
1414
]
1515
# @takumi-rs/core ships platform-specific .node binaries via napi-rs's runtime
16-
# require() dispatcher — esbuild can't statically trace the optional deps, so
17-
# the Linux binary is missing from the zipped function. Keep the package
18-
# external so node_modules/@takumi-rs/core (and the matching @takumi-rs/core-
19-
# linux-x64-gnu installed by pnpm on the build machine) is shipped as-is.
20-
external_node_modules = ["@takumi-rs/core"]
16+
# require() dispatcher — esbuild can't statically trace the optional deps. Keep
17+
# the napi loader external so node_modules/@takumi-rs/core ships as-is, and
18+
# also list the Linux x64 binary package explicitly: Netlify's bundler only
19+
# follows declared deps for `external_node_modules`, so the optional platform
20+
# package would otherwise be dropped (verified — function failed at runtime
21+
# with "Cannot find native binding"). Netlify functions run on AWS Lambda
22+
# Amazon Linux 2 (glibc, x64), hence linux-x64-gnu.
23+
external_node_modules = [
24+
"@takumi-rs/core",
25+
"@takumi-rs/core-linux-x64-gnu",
26+
]
2127

2228
[[headers]]
2329
for = "/*"

0 commit comments

Comments
 (0)