Commit e88b3f7
fix(build): generalize the napi-binary vendoring fix to @ngrok/ngrok (F1)
Code review of the impit fix (3b71a39) found the identical unfixed defect one
package over: @ngrok/ngrok declares 13 per-platform optionalDependencies for its
own NAPI binding (@ngrok/ngrok-win32-x64-msvc, etc.), and prepare-package-deps.mjs
was still copying only the bare @ngrok/ngrok folder. A packaged-VSIX user who
enables the ngrok tunnel provider would hit "Cannot find native binding" the same
way AIRTABLE_HTTP_CLIENT=impit did before that fix.
Rather than hardcode a second package name, generalize the mechanism: after
copying any package in packagesToCopy, read ITS OWN optionalDependencies (from
the already-copied dist/node_modules/<name>/package.json, sidestepping strict
`exports` maps like otpauth's) and vendor whichever resolve from this machine.
Entries shaped like NAPI platform splits (child name prefixed with the parent's
own name — impit-<platform>, @ngrok/ngrok-<platform>) trigger a loud aggregate
warning if none resolve; other optional deps (e.g. patchright's fsevents, a
genuinely-optional macOS file watcher) are still vendored when available but
don't warrant the same alarm when missing. This closes the whole class of bug
for every currently-vendored dependency and any future addition, not just the
two packages known to hit it today.
Verified against a real rebuilt VSIX (pnpm packx:no-bump): both
dist/node_modules/impit-win32-x64-msvc/impit-node.win32-x64-msvc.node and
dist/node_modules/@ngrok/ngrok-win32-x64-msvc/ngrok.win32-x64-msvc.node are now
present; `import('@ngrok/ngrok')` from the extracted VSIX tree loads the real
native binding (connect(), Session, etc. present). Falsification control: moving
the vendored @ngrok/ngrok-win32-x64-msvc folder away reproduces
`Cannot find module '@ngrok/ngrok-win32-x64-msvc'` (MODULE_NOT_FOUND) — the exact
shape the repo's own isNativeMissingError() regex already matches — and restoring
it fixes the load again. Confirmed the scope boundary the reviewer asked about:
ngrok.js's isNgrokNativeAvailable()/isSetupComplete() already degrade this
failure to a typed NgrokNativeMissingError / {ready:false, reason} instead of
crashing anything — verified live by running the real ngrok.js from a directory
tree with @ngrok/ngrok genuinely unresolvable (exit 0, no crash, typed error
surfaced).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 3b71a39 commit e88b3f7
1 file changed
Lines changed: 55 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
165 | 190 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
183 | 196 | | |
184 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
185 | 209 | | |
186 | | - | |
187 | | - | |
188 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
189 | 213 | | |
190 | | - | |
| 214 | + | |
191 | 215 | | |
192 | 216 | | |
193 | 217 | | |
194 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
195 | 225 | | |
196 | 226 | | |
197 | 227 | | |
| |||
0 commit comments