webnek 0.1.4 → 0.1.5

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/bin/cli.mjs CHANGED
@@ -117,6 +117,25 @@ function copyTemplate(from, to, vars) {
117
117
  }
118
118
  }
119
119
 
120
+ // Vercel's Rust builder (@vercel/rust) parses .cargo/config.toml whenever it
121
+ // exists and reads `build.target` without checking that a [build] table is
122
+ // present. An alias-only config kills every deploy with
123
+ // "Cannot read properties of undefined (reading 'target')".
124
+ // Guarantee scaffolded apps never ship that footgun.
125
+ function healCargoConfig(appDir) {
126
+ const p = join(appDir, ".cargo", "config.toml");
127
+ if (!existsSync(p)) return;
128
+ const text = readFileSync(p, "utf8");
129
+ const hasBuild = text
130
+ .split("\n")
131
+ .some((l) => /^\s*(\[build[\].]|build\.)/.test(l));
132
+ if (hasBuild) return;
133
+ writeFileSync(
134
+ p,
135
+ `${text.endsWith("\n") ? text : `${text}\n`}\n# Vercel's Rust builder requires a [build] table to exist when this file does.\n[build]\n`
136
+ );
137
+ }
138
+
120
139
  function stripNodeManifests(appDir) {
121
140
  for (const leftover of [
122
141
  "package.json",
@@ -186,6 +205,7 @@ function scaffold(targetArg) {
186
205
  PROJECT_NAME: pkgName,
187
206
  });
188
207
  stripNodeManifests(appDir);
208
+ healCargoConfig(appDir);
189
209
 
190
210
  const rel = relative(process.cwd(), appDir) || ".";
191
211
  const built = cargoBuild(appDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webnek",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Create a Webnek app. bun create webnek@latest my-app && cargo dev",
5
5
  "type": "module",
6
6
  "license": "MIT OR Apache-2.0",
@@ -1,2 +1,6 @@
1
1
  [alias]
2
2
  dev = "run"
3
+
4
+ # Vercel's Rust builder requires a [build] table to exist when this file does
5
+ # (it reads `build.target` unconditionally). Keep this even if empty.
6
+ [build]
@@ -3,3 +3,6 @@ target/**
3
3
  !target/x86_64-unknown-linux-gnu/release/**
4
4
  !target/aarch64-unknown-linux-gnu/release/**
5
5
  .git
6
+ # Local cargo config (the `cargo dev` alias) — a config without a [build]
7
+ # table crashes @vercel/rust, and none of it is needed on Vercel.
8
+ .cargo
@@ -13,3 +13,7 @@ cargo dev
13
13
  ```bash
14
14
  vercel
15
15
  ```
16
+
17
+ Vercel compiles `api/index.rs` into a Rust function; everything else rewrites to it (`vercel.json`).
18
+
19
+ Note: `.cargo/config.toml` must keep a `[build]` table (even empty) — Vercel's Rust builder crashes on configs without one. `.vercelignore` also keeps `.cargo` out of deploys.