Home / Function/ isInternalModule() — react Function Reference

isInternalModule() — react Function Reference

Architecture documentation for the isInternalModule() function in moduleFilters.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4b8ff33d_f91f_6a04_31db_7d18423189ad["isInternalModule()"]
  efac6299_4c18_f347_3941_cc54822e7b6f["moduleFilters.js"]
  4b8ff33d_f91f_6a04_31db_7d18423189ad -->|defined in| efac6299_4c18_f347_3941_cc54822e7b6f
  a2777e3e_5de8_64fd_2831_e7d1431e9806["draw()"]
  a2777e3e_5de8_64fd_2831_e7d1431e9806 -->|calls| 4b8ff33d_f91f_6a04_31db_7d18423189ad
  style 4b8ff33d_f91f_6a04_31db_7d18423189ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-timeline/src/content-views/utils/moduleFilters.js lines 21–73

export function isInternalModule(
  internalModuleSourceToRanges: InternalModuleSourceToRanges,
  flamechartStackFrame: FlamechartStackFrame,
): boolean {
  const {locationColumn, locationLine, scriptUrl} = flamechartStackFrame;

  if (scriptUrl == null || locationColumn == null || locationLine == null) {
    // This could indicate a browser-internal API like performance.mark().
    return false;
  }

  // Internal modules are only registered if DevTools was running when the profile was captured,
  // but DevTools should also hide its own frames to avoid over-emphasizing them.
  if (
    // Handle webpack-internal:// sources
    scriptUrl.includes('/react-devtools') ||
    scriptUrl.includes('/react_devtools') ||
    // Filter out known extension IDs
    scriptUrl.includes(CHROME_WEBSTORE_EXTENSION_ID) ||
    scriptUrl.includes(INTERNAL_EXTENSION_ID) ||
    scriptUrl.includes(LOCAL_EXTENSION_ID)
    // Unfortunately this won't get everything, like relatively loaded chunks or Web Worker files.
  ) {
    return true;
  }

  // Filter out React internal packages.
  const ranges = internalModuleSourceToRanges.get(scriptUrl);
  if (ranges != null) {
    for (let i = 0; i < ranges.length; i++) {
      const [startStackFrame, stopStackFrame] = ranges[i];

      const isAfterStart =
        // $FlowFixMe[invalid-compare] -- TODO: Revealed when adding types to error-stack-parser
        locationLine > startStackFrame.lineNumber ||
        (locationLine === startStackFrame.lineNumber &&
          // $FlowFixMe[invalid-compare]
          locationColumn >= startStackFrame.columnNumber);
      const isBeforeStop =
        // $FlowFixMe[invalid-compare]
        locationLine < stopStackFrame.lineNumber ||
        (locationLine === stopStackFrame.lineNumber &&
          // $FlowFixMe[invalid-compare]
          locationColumn <= stopStackFrame.columnNumber);

      if (isAfterStart && isBeforeStop) {
        return true;
      }
    }
  }

  return false;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does isInternalModule() do?
isInternalModule() is a function in the react codebase, defined in packages/react-devtools-timeline/src/content-views/utils/moduleFilters.js.
Where is isInternalModule() defined?
isInternalModule() is defined in packages/react-devtools-timeline/src/content-views/utils/moduleFilters.js at line 21.
What calls isInternalModule()?
isInternalModule() is called by 1 function(s): draw.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free