Summary
Object-literal members (shorthand methods, key: function () {}, key: () => {}) are extracted as nodes only when the containing object is an export const. The same object without export, an object literal assigned to a member expression (window.api = { … }, ns.mod = { … }), or one declared inside an IIFE produces no member nodes at all.
That makes classic script-tag JavaScript — no modules, namespaces hung off window — almost invisible: the namespace constant is indexed, every method inside it is not. Related but distinct from #1573 / #1932, which are about edges to members that were already extracted.
Repro (v1.6.1, Windows x64, npm global install)
// src/a_export.ts
export const objTsExp = { tsExpM() { return 1; }, tsExpProp: () => 1 };
// src/b_plain.ts
const objTsPlain = { tsPlainM() { return 1; }, tsPlainProp: () => 1 };
// src/c_export.js
export const objJsExp = { jsExpM() { return 1; }, jsExpProp: () => 1 };
// src/d_plain.js
const objJsPlain = { jsPlainM() { return 1; }, jsPlainProp: () => 1 };
// src/e_iife.js
(function () {
const objIife = { iifeM() { return 1; } };
window.WS = { wsM() { return objIife.iifeM(); } };
})();
git init && git add -A && codegraph init -y ., then all non-file nodes:
src/a_export.ts constant objTsExp
src/a_export.ts function tsExpM
src/a_export.ts function tsExpProp
src/b_plain.ts constant objTsPlain
src/c_export.js constant objJsExp
src/c_export.js function jsExpM
src/c_export.js function jsExpProp
src/d_plain.js constant objJsPlain
| Container |
Members extracted? |
export const o = { m() {} } (.ts / .js) |
yes |
const o = { m() {} } (.ts / .js) |
no |
window.X = { m() {} } |
no (no node for X either) |
| object literal inside an IIFE |
no |
A class method in the same file is extracted (class Svc { classMethod() {} } → method classMethod), so it is specific to object-literal containers.
Knock-on effects
- Calls made inside an unextracted member are attributed to the enclosing constant:
codegraph callers helper lists constant store instead of store.shorthand.
- For
window.api = { load() { return store.shorthand(); } } the call is lost entirely — there is no node to hang the edge on.
codegraph_explore for such a method name does not say "not found"; it returns ~26 KB of unrelated, loosely matching source, which costs more tokens than a grep would.
Real-world scale
A vanilla-JS browser app (script tags, no bundler, namespaces on window): 200 files under public/js, 670 method-shorthand definitions inside object literals, 0 present in the graph. The single largest module has 251 such methods; the shared auth / API-client modules are written the same way. Plain function declarations and nested arrows in the same files are indexed fine (~13k function nodes).
Expected
Object-literal members get nodes (qualified as container.member) regardless of whether the container is exported — including const objects, member-expression assignments (window.X = {…}, a.b = {…}), and objects inside IIFEs — the same way the exported case already works.
Summary
Object-literal members (shorthand methods,
key: function () {},key: () => {}) are extracted as nodes only when the containing object is anexport const. The same object withoutexport, an object literal assigned to a member expression (window.api = { … },ns.mod = { … }), or one declared inside an IIFE produces no member nodes at all.That makes classic script-tag JavaScript — no modules, namespaces hung off
window— almost invisible: the namespace constant is indexed, every method inside it is not. Related but distinct from #1573 / #1932, which are about edges to members that were already extracted.Repro (v1.6.1, Windows x64, npm global install)
git init && git add -A && codegraph init -y ., then all non-file nodes:export const o = { m() {} }(.ts / .js)const o = { m() {} }(.ts / .js)window.X = { m() {} }Xeither)A class method in the same file is extracted (
class Svc { classMethod() {} }→method classMethod), so it is specific to object-literal containers.Knock-on effects
codegraph callers helperlistsconstant storeinstead ofstore.shorthand.window.api = { load() { return store.shorthand(); } }the call is lost entirely — there is no node to hang the edge on.codegraph_explorefor such a method name does not say "not found"; it returns ~26 KB of unrelated, loosely matching source, which costs more tokens than a grep would.Real-world scale
A vanilla-JS browser app (script tags, no bundler, namespaces on
window): 200 files underpublic/js, 670 method-shorthand definitions inside object literals, 0 present in the graph. The single largest module has 251 such methods; the shared auth / API-client modules are written the same way. Plainfunctiondeclarations and nested arrows in the same files are indexed fine (~13k function nodes).Expected
Object-literal members get nodes (qualified as
container.member) regardless of whether the container is exported — includingconstobjects, member-expression assignments (window.X = {…},a.b = {…}), and objects inside IIFEs — the same way the exported case already works.