mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
Packages such as pi-tui look for their prebuilt Node-API addons at run time: a createRequire require call with a computed path, and the loader's resolve passed as a value, each inside a try block whose catch takes a fallback. Preflight refused these packages. Preflight now classifies each use of a createRequire loader. Inside the try block of a try statement in the same function, a call with a computed specifier or another argument shape, and resolve or resolve.paths read as a value, no longer refuse the package. Outside a try block they keep it refused, with a reason that names the computed specifier. The loader itself as a value, writes and optional calls stay refused. In JavaScript source, such a call evaluates its arguments and then throws a runtime fence, and the resolve value is a function that throws one when called, so `(options.resolve ?? require.resolve)(id)` still calls the option. Both are listed in coverage as deferred to runtime. TypeScript source keeps the compile-time refusals. Refs #1777