You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JavaScript: require('..') of a directory with package.json "main" isn't followed; the call links to the local const #2964
A relative require() of a directory whose entry file is named by that directory's package.json"main" isn't followed. This includes require('..') and require('../') from a test folder up to the package root. The call then links to the local const holding the require result, a calls edge to a variable in the same file, and the real entry function gets no callers.
A directory with an index.js resolves; only the "main" lookup is missing for relative directory paths.
Reproduced on main at 72f398a with CODEGRAPH_KERNEL=0. Linux/WSL2, Node 22.23.2.
Where it shows up. Every fastify (5df959f) test starts with const Fastify = require('..') (root package.json has "main": "fastify.js") and calls Fastify(). Checking every calls edge against the TypeScript checker (allowJs), 1,191 edges in fastify are these calls linking to each test file's own Fastify constant, and fastify() in fastify.js gets none of them as callers. require('..') / require('../..') from test/ is the usual way a package's tests load the package.
Expected. Resolve a relative directory specifier the way Node does: <dir>/package.json"main" (then <dir>/index.js). Also, a call through a binding that holds a require() result shouldn't become a calls edge to the binding's own const node.
Related: #2799 / #2502 (the same package.json entry lookup for a workspace package's name), #2263, #2189.
Activity