Repository navigation
Conversation
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
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+2361
to
+2369
| if (ts.isCallExpression(call) && call.expression === use) { | ||
| if (call.questionDotToken) return "escaping"; | ||
| if (call.arguments.nodes.length === 1 && ts.isStringLiteralLike(call.arguments.nodes[0]!)) | ||
| return "static"; | ||
| } else if (!member || isAssignmentTarget7(use)) { | ||
| return "escaping"; | ||
| } | ||
| return insideTryBlock7(use) ? "deferred" : "computed"; | ||
| } |
Contributor
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
require(computedPath)through createRequire,require.resolvepassed as a value), such as pi-tui, compile under--npm-static. Those uses throw where they run, the package takes its fallback, and coverage lists them as deferred. Refs 0.4.1: remaining --npm-static=auto refusals for a pi-coding-agent worker (namespace re-export cycle, createRequire computed specifier, CJS entries not joining) #1777.