What
src/modules/react-loader/extract-component.ts:19-20:
const firstKey = Object.keys(moduleObj)[0];
const component = moduleObj.default ?? (firstKey ? moduleObj[firstKey] : undefined);
For a transpiled CommonJS namespace shaped { __esModule: true, Named }, moduleObj.default is undefined, firstKey is "__esModule", and the extracted "component" is therefore the boolean true.
That shape is what many transpilers emit for a module with only named exports, so this is not an exotic input.
Impact
The caller receives true where it expects a component. Rendering it fails later and further from the cause than it would if extraction had returned undefined.
Suggested fix
Skip the __esModule marker (and any non-function, non-object value) when falling back to the first key, or fall back only to keys that look like components.
Provenance
Found during a test-quality audit of src/modules (PR #4058). Deliberately not asserted in that PR — writing a test around the current output would enshrine the wrong behavior as correct, which is the opposite of what the audit is for. Reported here instead so the fix can decide the intended contract.
What
src/modules/react-loader/extract-component.ts:19-20:For a transpiled CommonJS namespace shaped
{ __esModule: true, Named },moduleObj.defaultisundefined,firstKeyis"__esModule", and the extracted "component" is therefore the booleantrue.That shape is what many transpilers emit for a module with only named exports, so this is not an exotic input.
Impact
The caller receives
truewhere it expects a component. Rendering it fails later and further from the cause than it would if extraction had returnedundefined.Suggested fix
Skip the
__esModulemarker (and any non-function, non-object value) when falling back to the first key, or fall back only to keys that look like components.Provenance
Found during a test-quality audit of
src/modules(PR #4058). Deliberately not asserted in that PR — writing a test around the current output would enshrine the wrong behavior as correct, which is the opposite of what the audit is for. Reported here instead so the fix can decide the intended contract.